Convert some value classes to AutoValue

These classes were found by searching for custom hashCode
implementations, and omitting some cases:

 - Classes requiring custom serialization, which is not supported[1][2].
 - Most instances with custom hashCode or equals implementations,
   where the code savings is not as significant.
 - All classes in the extension API. We may migrate these eventually,
   but let's avoid this large backwards incompatible change until
   we're more used to AutoValue elsewhere.
 - All classes in the UI package.[3]

There are likely still more value classes that were missed by this
search that do not implement equals or hashCode.

[1] https://github.com/google/auto/tree/master/value#serialization
[2] This excludes, among other things, all persistent cache keys. It
might be possible to convert persistent caches to use a key
marshalling strategy other than Java serialization, but probably not
without invalidating all existing entries.
[3] This should still be possible as generated classes are generally
GWT compatible.

Change-Id: I96796b9879b7e487b80949b63115ac4032180f8b
This commit is contained in:
Dave Borowitz
2014-11-09 17:57:45 -08:00
parent c87d29ec16
commit eba26614e5
24 changed files with 159 additions and 332 deletions

View File

@@ -137,7 +137,7 @@ public class LabelNormalizerTest {
PatchSetApproval cr = psa(userId, "Code-Review", 2);
PatchSetApproval v = psa(userId, "Verified", 1);
assertEquals(new Result(
assertEquals(Result.create(
list(v),
list(copy(cr, 1)),
list()),
@@ -153,7 +153,7 @@ public class LabelNormalizerTest {
PatchSetApproval cr = psa(userId, "Code-Review", 5);
PatchSetApproval v = psa(userId, "Verified", 5);
assertEquals(new Result(
assertEquals(Result.create(
list(),
list(copy(cr, 2), copy(v, 1)),
list()),
@@ -164,7 +164,7 @@ public class LabelNormalizerTest {
public void emptyPermissionRangeOmitsResult() throws Exception {
PatchSetApproval cr = psa(userId, "Code-Review", 1);
PatchSetApproval v = psa(userId, "Verified", 1);
assertEquals(new Result(
assertEquals(Result.create(
list(),
list(),
list(cr, v)),
@@ -179,7 +179,7 @@ public class LabelNormalizerTest {
PatchSetApproval cr = psa(userId, "Code-Review", 0);
PatchSetApproval v = psa(userId, "Verified", 0);
assertEquals(new Result(
assertEquals(Result.create(
list(cr),
list(),
list(v)),

View File

@@ -23,23 +23,23 @@ public class LabelVoteTest {
public void parse() {
LabelVote l;
l = LabelVote.parse("Code-Review-2");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) -2, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) -2, l.value());
l = LabelVote.parse("Code-Review-1");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) -1, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) -1, l.value());
l = LabelVote.parse("-Code-Review");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 0, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 0, l.value());
l = LabelVote.parse("Code-Review");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 1, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 1, l.value());
l = LabelVote.parse("Code-Review+1");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 1, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 1, l.value());
l = LabelVote.parse("Code-Review+2");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 2, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 2, l.value());
}
@Test
@@ -55,26 +55,26 @@ public class LabelVoteTest {
public void parseWithEquals() {
LabelVote l;
l = LabelVote.parseWithEquals("Code-Review=-2");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) -2, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) -2, l.value());
l = LabelVote.parseWithEquals("Code-Review=-1");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) -1, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) -1, l.value());
l = LabelVote.parseWithEquals("Code-Review=0");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 0, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 0, l.value());
l = LabelVote.parseWithEquals("Code-Review=1");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 1, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 1, l.value());
l = LabelVote.parseWithEquals("Code-Review=+1");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 1, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 1, l.value());
l = LabelVote.parseWithEquals("Code-Review=2");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 2, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 2, l.value());
l = LabelVote.parseWithEquals("Code-Review=+2");
assertEquals("Code-Review", l.getLabel());
assertEquals((short) 2, l.getValue());
assertEquals("Code-Review", l.label());
assertEquals((short) 2, l.value());
}
@Test