@Retention(value=SOURCE)
@Target(value=PARAMETER)
public @interface Default
Specifies the default value for the property corresponding to a constructor parameter in an immutable class. This allows the generated Builder class to work correctly when no value is supplied for that parameter.
| Modifier and Type | Required Element and Description |
|---|---|
java.lang.String |
value
The default value for this parameter, specified as a string value that
can be used in an initializer.
|
public abstract java.lang.String value
The default value for this parameter, specified as a string value that
can be used in an initializer. For example, it could be "1.0" for
a parameter of type double. An empty string can be used to
indicate the default value for the parameter of this type, so
@Default("") would indicate 0.0 for a parameter of type
double or null for a parameter of type String.
Note: for parameters of type String, it is easy to forget the
quotes around a string literal. A string parameter whose default is the
empty string would be specified like this:
@Default("\"\"") name.