-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge Google changes as of 2016-05-10 #328
Conversation
…uote some instances of `@AutoValue` that needed it. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=119101365
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=119453753
git commit: dfcf55e5fc3f29ac55847a19627f9f15d3aff370 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=119557171
…est practices: [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=119568091
…ou are using JavaBeans conventions (like getFoo()) but you aren't because at least one method isn't. Then a Builder setter like setFoo will be rejected because it would have had to be called setGetFoo. This change detects that this might have happened and shows a list of the methods that prevented the JavaBeans conventions from being applied. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=119569372
… from an earlier draft version of the Extensions API. This is google#322 by @lucastsa. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=119896497
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120482220
…his involves moving a fair amount of code around, but the resultant organization for method identification should be clearer. The principal purpose of the restructuring is to get rid of warnings about abstract methods when those methods are going to be implemented by an extension. A second purpose is to fix a bug where extensions would not work right if there was a toBuilder() method. Also improve the test coverage in ExtensionTest, which was fairly minimal. Some of the code in this change is based on google#299 by @rharter. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120485500
Limitations: The following cases currently don't work with javac (i.e. the annotation processors don't see the @nullable so a null check is generated in the constructor): public abstract int @nullable [] getInts() This works with eclipse JDT and the null check is ommited in the generated code, but note that the @nullable is in the wrong position in the generated code (i.e. @nullable int[] instead of int @nullable[])), which might lead to compiler warnings For generic type T: @nullable public abstract T getT() (works in JDT) Also @nullable won't work for types which can't be imported because of naming conflicts, because the @nullable is generated at the wrong place, i.e. "@nullable some.package.Map" instead of "some.package.@nullable Map" which won't compile at all for TYPE_USE @nullable. This change was imported from github: google#293 The original author is Till Brychy. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120629206
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120629767
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120714957
… Previously it treated all annotations with the same SimpleName as being overload attempts. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120715929
…mpty(). Also, in the AutoValue_Foo constructor, do not check for nullness if there is a builder, because the constructor is private and the build() method will check for nullness before calling it. The effect on generated code is visible in CompilationTest (I recommend "Expand whole file"). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120933175
… via a setter with an argument of type T. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120943277
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=120944222
…ilder can have type Optional<T> and it will return Optional.of(x) where x is the value that has been set in the Builder, or Optional.empty() if no value has been set. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=121591500
…xtends Builder<B>> idiom. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=121886725
LGTM |
"In AutoValue builders, support setting a property of type Optional via a setter with an argument of type T." Why did you use |
This probably isn't the best place to have this discussion, but we did deliberately decide against allowing a null argument here. We didn't feel that it would be appropriate to distort the semantics just because null and empty feel sort of like the same thing. It's at least as likely that you would want to get a NullPointerException when the argument is null as that you would want Optional.empty(). This is any case only a minor convenience. You can always write explicitly: @AutoValue.Builder
public abstract static class Builder {
public Builder setFoo(String foo) {
return setFoo(Optional.ofNullable(foo));
}
abstract Builder setFoo(Optional<String> foo);
} |
@AutoValue.Builder
to extend a parent builder using the<B extends Builder<B>>
idiom.Optional<T>
and it will returnOptional.of(x)
wherex
is the value that has been set in the Builder, orOptional.empty()
if no value has been set.Optional<T>
via a setter with an argument of typeT
.Optional.empty()
.@Nullable
. This is patch for "AutoValue should respect @Nullable annotations on types #283" #293 by @brychcy.@AutoValue
that needed it.