@Target(value=TYPE) @Retention(value=SOURCE) public @interface Value
private and final to each field.
@Value is a shorthand for:final @Getter @Wither @FieldDefaults(makeFinal=true,level=AccessLevel.PRIVATE) @EqualsAndHashCode @ToString @AllArgsConstructor.
If any method to be generated already exists (in name and parameter c ount - the return type or parameter types are not relevant), then that method will not be generated by the Value annotation.
The generated constructor will have 1 parameter for each field. The generated toString will print all fields,
while the generated hashCode and equals take into account all non-transient fields.
Static fields are skipped (no getter or setter, and they are not included in toString, equals, hashCode, or the constructor).
toString, equals, and hashCode use the deepX variants in the
java.util.Arrays utility class. Therefore, if your class has arrays that contain themselves,
these methods will just loop endlessly until the inevitable StackOverflowError. This behaviour
is no different from java.util.ArrayList, though.
| Modifier and Type | Optional Element and Description |
|---|---|
String |
staticConstructor
If you specify a static constructor name, then the generated constructor will be private, and
instead a static factory method is created that other classes can use to create instances.
|
public abstract String staticConstructor
public @Data(staticConstructor = "of") class Point { final int x, y; }
Default: No static constructor, instead the normal constructor is public.Copyright © 2009-2011 The Project Lombok Authors, licensed under the MIT licence.