Annotation Type Data
-
@Target(TYPE) @Documented @GwtCompatible public @interface Data
Turns this class into a read-only Data object.All non-static, non-transient fields ("data fields") become final and a getter is created for each one. For primitive boolean properties, the "is"-prefix is used. The generation of getters can be customized using the
Accessors
annotation.If there is no user-defined constructor, a constructor taking all data fields will be generated. If there already is a constructor, but you want the default one on top of that, you can use the
FinalFieldsConstructor
annotation.Default implementations for
equals
andhashCode
are added if they don't exist yet. SeeEqualsHashCode
for details. AtoString
method is added if it doesn't exist yet. SeeToString
for details and customization options.Note: Although no setters are generated, this annotation does not enforce immutability. Objects passed into the constructor or returned by the getters could be modified by clients. If immutability is required, you need to implement appropriate defensive copying.
- Since:
- 2.7