Treat property builders for nested @AutoValue types more like property builders for collections. If we have `ImmutableList<String> strings()` and `ImmutableList.Builder<String> stringsBuilder()`, then the list starts off empty. If you never add anything to it, the final result is an empty list. Likewise, if we have `NestedAutoValueType foo()` and `NestedAutoValueType.Builder fooBuilder()`, then `foo` starts off with its default value. If you never set anything in fooBuilder(), the final result is a default NestedAutoValueType. We only construct that default value lazily, so if you do in fact set something on the builder then the default instance of NestdAutoValueType is never constructed. This fixes a bug: previously if you never called fooBuilder() then the containing object would be built with a null NestedAutoValueType, even if foo() was not @Nullable. Now it will be built with a default NestedAutoValueType, and if some properties in NestedAutoValueType don't have defaults you will get an exception. The previous behaviour was that `strings()` could never be null, even if it was @Nullable, because the builder started off with a value of ImmutableList.of(). That seems acceptable and even desirable, since a @Nullable ImmutableList invites confusion as to the difference between an empty list and a null one. So now we forbid having a property builder for a property that is @Nullable, whether a collection or a nested @AutoValue. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148559773
A collection of source code generators for Java.
Java is full of code that is mechanical, repetitive, typically untested and sometimes the source of subtle bugs. Sounds like a job for robots!
The Auto subprojects are a collection of code generators that automate those types of tasks. They create the code you would have written, but without the bugs.
Save time. Save code. Save sanity.
AutoFactory - JSR-330-compatible factories
Latest version: 0.1-beta3
AutoService - Provider-configuration files for ServiceLoader
Latest version: 1.0-rc2
AutoValue - Immutable value-type code generation for Java 1.6+.
Latest version: 1.3
Common - Helper utilities for writing annotation processors.
Latest version: 0.6
Copyright 2013 Google, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.