@Retention(value=RUNTIME)
public @interface SetFromFlag
This is used to automate the processing where named arguments are passed in constructors and other methods, and the values of those named arguments should be transferred to other known fields/arguments/objects at runtime.
Fields on a class are typically set from values in a map with a call to
FlagUtils.setFieldsFromFlags(java.util.Map, Object)
.
That method (and related, in the same class) will attend to the arguments here.
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
defaultVal
The default value, if it is not explicitly set.
|
boolean |
immutable
whether the object should not be changed once set; defaults to false
|
boolean |
nullable
whether the object is required & should not be set to null; defaults to true.
|
java.lang.String |
value
the flag (key) which should be used to find the value; if empty defaults to field/argument/object name
|
public abstract java.lang.String value
public abstract boolean immutable
this is partially tested for in many routines, but not all; when nullable=false the testing (when done) is guaranteed. however if nullable is allowed we do not distinguish between null and unset so explicitly setting null then setting to a value is not detected as an illegal mutating.
public abstract boolean nullable
FlagUtils.checkRequiredFields(Object)
has the effect of requiring a value)
code should call that method explicitly to enforce nullable false; errors are not done during a call to setFieldsFromFlags because fields may be initialised in multiple passes.)
this is partially tested for in many routines, but not all
public abstract java.lang.String defaultVal
The value will be coerced from String where required, for types supported by TypeCoercions
.
The field will be initialised with its default value on the first call to setFieldsFromFlags (or related). (The field will not be initialised if that method is not called.)