0
# Constructors
1
2
Automatic constructor generation with support for required arguments, all arguments, and no-argument constructors.
3
4
## Capabilities
5
6
### @NoArgsConstructor
7
8
```java { .api }
9
@Target(ElementType.TYPE)
10
@Retention(RetentionPolicy.SOURCE)
11
public @interface NoArgsConstructor {
12
String staticName() default "";
13
AnyAnnotation[] onConstructor() default {};
14
AccessLevel access() default AccessLevel.PUBLIC;
15
boolean force() default false;
16
}
17
```
18
19
### @AllArgsConstructor
20
21
```java { .api }
22
@Target(ElementType.TYPE)
23
@Retention(RetentionPolicy.SOURCE)
24
public @interface AllArgsConstructor {
25
String staticName() default "";
26
AnyAnnotation[] onConstructor() default {};
27
AccessLevel access() default AccessLevel.PUBLIC;
28
}
29
```
30
31
### @RequiredArgsConstructor
32
33
```java { .api }
34
@Target(ElementType.TYPE)
35
@Retention(RetentionPolicy.SOURCE)
36
public @interface RequiredArgsConstructor {
37
String staticName() default "";
38
AnyAnnotation[] onConstructor() default {};
39
AccessLevel access() default AccessLevel.PUBLIC;
40
}
41
```
42
43
**Usage Examples:**
44
45
```java
46
import lombok.*;
47
48
@NoArgsConstructor
49
@AllArgsConstructor
50
@RequiredArgsConstructor
51
public class Person {
52
private final String name; // Required field
53
private int age;
54
private String email;
55
}
56
57
// Generated constructors:
58
// public Person() {}
59
// public Person(String name, int age, String email) { ... }
60
// public Person(String name) { ... } // Required args only
61
```