diff options
author | emcmanus <emcmanus@google.com> | 2019-05-22 10:42:15 -0700 |
---|---|---|
committer | Ron Shapiro <shapiro.rd@gmail.com> | 2019-05-27 12:17:56 -0400 |
commit | b1d5393cbd791569088bedff44e1492dcc942d42 (patch) | |
tree | c317225d898ca4d0b28d29027a0dfda0de493d4a /value/src/test/java/com/google | |
parent | 48d65576f596e7889977c75bc188f2116570a5c8 (diff) | |
download | auto-b1d5393cbd791569088bedff44e1492dcc942d42.tar.gz |
Improve the logic for setter type conversion. Setter type conversion is when for example we have a property `Optional<String> foo()` or `ImmutableList<String> bar()` and a setter like `setFoo(String x)` or `setBar(String[] x)`. The generated setter will need to do `Optional.of(x)` or `ImmutableList.copyOf(x)`.
Previously the logic to do this was split into two places: (a) where we determined whether a conversion was possible, and (b) where we generated the code. In (b) we had to guess the name of the copy method (`of` or `copyOf` for example) even though we knew it in (a). Now we arrange for the information about the method name to be copied from (a) to (b).
This change will allow us to add logic to support ImmutableSortedSet.copyOfSorted and ImmutableSortedMap.copyOfSorted.
RELNOTES=n/a
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=249476752
Diffstat (limited to 'value/src/test/java/com/google')
-rw-r--r-- | value/src/test/java/com/google/auto/value/processor/AutoValueCompilationTest.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/value/src/test/java/com/google/auto/value/processor/AutoValueCompilationTest.java b/value/src/test/java/com/google/auto/value/processor/AutoValueCompilationTest.java index a3893ed1..32edfac4 100644 --- a/value/src/test/java/com/google/auto/value/processor/AutoValueCompilationTest.java +++ b/value/src/test/java/com/google/auto/value/processor/AutoValueCompilationTest.java @@ -2154,8 +2154,9 @@ public class AutoValueCompilationTest { .compile(javaFileObject); assertThat(compilation) .hadErrorContaining( - "Method without arguments should be a build method returning foo.bar.Baz" - + " or a getter method with the same name and type as a getter method of foo.bar.Baz") + "Method without arguments should be a build method returning foo.bar.Baz, or a getter" + + " method with the same name and type as a getter method of foo.bar.Baz, or" + + " fooBuilder() where foo() or getFoo() is a getter method of foo.bar.Baz") .inFile(javaFileObject) .onLine(12); } |