@Retention(SOURCE)
@Target(METHOD)
public @interface ImmutableDefaults
Each non-collection property in an immutable bean normally has to be initialized before use. This annotation allows default values to be set when creating the builder. Note that the defaults apply to the builder, not to the constructor of the bean.
The method must be a private static void instance method that takes a single argument of the type 'Builder'. Private is necessary as it is called from the builder constructor. For example:
@ImmutableDefaults
private static void applyDefaults(Builder builder) {
builder.group(Group.STANDARD); // default the group property to 'STANDARD'
}
Copyright © 2007–2018 Joda.org. All rights reserved.