Skip to content

Commit

Permalink
Reformat AutoValue source code using google-java-format. A few of the…
Browse files Browse the repository at this point in the history
… changes are arguably for the worse, but it's worth having a consistent format.

RELNOTES=Reformatted AutoValue source code using google-java-format.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198512874
  • Loading branch information
eamonnmcmanus authored and ronshapiro committed May 31, 2018
1 parent 0ffe45c commit 41d78d2
Show file tree
Hide file tree
Showing 72 changed files with 4,611 additions and 3,937 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import com.google.auto.value.AutoValue;
import java.util.Map;

/**
* @author [email protected] (Éamonn McManus)
*/
/** @author [email protected] (Éamonn McManus) */
public class PackagelessNestedValueType {
@AutoValue
public abstract static class Nested {
Expand Down
15 changes: 5 additions & 10 deletions value/src/it/functional/src/main/java/PackagelessValueType.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@ public abstract class PackagelessValueType {
// The getters here are formatted as an illustration of what getters typically look in real
// classes. In particular they have doc comments.

/**
* @return A string that is a nullable string.
*/
@Nullable public abstract String string();
/** @return A string that is a nullable string. */
@Nullable
public abstract String string();

/**
* @return An integer that is an integer.
*/
/** @return An integer that is an integer. */
public abstract int integer();

/**
* @return A non-null map where the keys are strings and the values are longs.
*/
/** @return A non-null map where the keys are strings and the values are longs. */
public abstract Map<String, Long> map();

public static PackagelessValueType create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

import java.util.Map;

/**
* @author [email protected] (Éamonn McManus)
*/
/** @author [email protected] (Éamonn McManus) */
public class NestedValueType {
@AutoValue
public abstract static class Nested {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@ public abstract class SimpleValueType {
// The getters here are formatted as an illustration of what getters typically look in real
// classes. In particular they have doc comments.

/**
* @return A string that is a nullable string.
*/
@Nullable public abstract String string();
/** @return A string that is a nullable string. */
@Nullable
public abstract String string();

/**
* @return An integer that is an integer.
*/
/** @return An integer that is an integer. */
public abstract int integer();

/**
* @return A non-null map where the keys are strings and the values are longs.
*/
/** @return A non-null map where the keys are strings and the values are longs. */
public abstract Map<String, Long> map();

public static SimpleValueType create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* @author [email protected] (Éamonn McManus)
*/
/** @author [email protected] (Éamonn McManus) */
@RunWith(JUnit4.class)
public class PackagelessValueTypeTest {
@Test
Expand All @@ -38,8 +36,8 @@ public void testPackagelessValueType() {
assertSame(happy, simple.string());
assertEquals(testInt, simple.integer());
assertSame(testMap, simple.map());
assertEquals("PackagelessValueType{string=happy, integer=23, map={happy=23}}",
simple.toString());
assertEquals(
"PackagelessValueType{string=happy, integer=23, map={happy=23}}", simple.toString());
int expectedHashCode = 1;
expectedHashCode = (expectedHashCode * 1000003) ^ happy.hashCode();
expectedHashCode = (expectedHashCode * 1000003) ^ ((Object) testInt).hashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,47 +27,67 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* @author [email protected] (Éamonn McManus)
*/
/** @author [email protected] (Éamonn McManus) */
@RunWith(JUnit4.class)
public class AutoAnnotationDefaultsTest {
@Retention(RetentionPolicy.RUNTIME)
@interface EverythingWithDefaults {
byte aByte() default 1;

short aShort() default 2;

int anInt() default 3;

long aLong() default Long.MAX_VALUE;

float aFloat() default Float.MAX_VALUE;

double aDouble() default -Double.MAX_VALUE;

char aChar() default '#';

boolean aBoolean() default true;

String aString() default "maybe\nmaybe not\n";

String spaces() default " ( x ) , ( y )"; // ensure the formatter doesn't eat spaces

MyEnum anEnum() default MyEnum.TWO;

byte[] bytes() default {-1, 0, 1};

short[] shorts() default {-2, 0, 2};

int[] ints() default {};

long[] longs() default {-Long.MAX_VALUE};

float[] floats() default {
-Float.MIN_VALUE, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NaN,
};

double[] doubles() default {
-Double.MIN_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN,
};

char[] chars() default {'f', '\n', '\uffef'};

boolean[] booleans() default {false, true};

String[] strings() default {"", "\uffef\n"};

MyEnum[] enums() default {MyEnum.ONE, MyEnum.TWO};
}

@AutoAnnotation static EverythingWithDefaults newEverythingWithDefaults() {
@AutoAnnotation
static EverythingWithDefaults newEverythingWithDefaults() {
return new AutoAnnotation_AutoAnnotationDefaultsTest_newEverythingWithDefaults();
}

@Test
public void testDefaults() throws Exception {
@EverythingWithDefaults class Annotated {}
@EverythingWithDefaults
class Annotated {}
EverythingWithDefaults expected = Annotated.class.getAnnotation(EverythingWithDefaults.class);
EverythingWithDefaults actual = newEverythingWithDefaults();

Expand All @@ -79,18 +99,21 @@ public void testDefaults() throws Exception {
Object expectedValue = member.invoke(expected);
Object actualValue = member.invoke(actual);
if (!equal(expectedValue, actualValue)) {
differencesBuilder.append("For ").append(name)
.append(" expected <").append(string(expectedValue))
.append("> but was <").append(string(actualValue)).append(">\n");
differencesBuilder
.append("For ")
.append(name)
.append(" expected <")
.append(string(expectedValue))
.append("> but was <")
.append(string(actualValue))
.append(">\n");
}
}
String differences = differencesBuilder.toString();
assertTrue(differences, differences.isEmpty());

// All the members were the same. Check that the equals and hashCode results say so too.
new EqualsTester()
.addEqualityGroup(expected, actual)
.testEquals();
new EqualsTester().addEqualityGroup(expected, actual).testEquals();
}

private static boolean equal(Object x, Object y) {
Expand Down
Loading

0 comments on commit 41d78d2

Please sign in to comment.