Package lombok
Annotation Type RequiredArgsConstructor
-
@Target(TYPE) @Retention(SOURCE) public @interface RequiredArgsConstructorGenerates a constructor with required arguments. Required arguments are final fields and fields with constraints such as@NonNull.Complete documentation is found at the project lombok features page for @Constructor.
Even though it is not listed, this annotation also has the
onConstructorparameter. See the full documentation for more details.- See Also:
NoArgsConstructor,AllArgsConstructor
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description AccessLevelaccessSets the access level of the constructor.RequiredArgsConstructor.AnyAnnotation[]onConstructorAny annotations listed here are put on the generated constructor.java.lang.StringstaticNameIf set, the generated constructor will be private, and an additional static 'constructor' is generated with the same argument list that wraps the real constructor.
-
-
-
Element Detail
-
staticName
java.lang.String staticName
If set, the generated constructor will be private, and an additional static 'constructor' is generated with the same argument list that wraps the real constructor. Such a static 'constructor' is primarily useful as it infers type arguments.- Returns:
- Name of static 'constructor' method to generate (blank = generate a normal constructor).
- Default:
- ""
-
-
-
onConstructor
RequiredArgsConstructor.AnyAnnotation[] onConstructor
Any annotations listed here are put on the generated constructor. The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
up to JDK7:
@RequiredArgsConstructor(onConstructor=@__({@AnnotationsGoHere}))
from JDK8:
@RequiredArgsConstructor(onConstructor_={@AnnotationsGohere})// note the underscore afteronConstructor.- Returns:
- List of annotations to apply to the generated constructor.
- Default:
- {}
-
-
-
access
AccessLevel access
Sets the access level of the constructor. By default, generated constructors arepublic.- Returns:
- The constructor will be generated with this access modifier.
- Default:
- lombok.AccessLevel.PUBLIC
-
-