@RequiredArgsConstructor
final이나 @NonNull인 필드 값만 파라미터로 받는 생성자를 추가
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class Person {
private final String name;
private final int age;
private String address;
}
public class Main {
public static void main(String[] args) {
Person person1 = new Person("John", 30);
}
}
https://standout.tistory.com/176
상수, final
상수, 대문자로 표시하는것이 관례 double PI=3.14; final double PI=3.14 https://standout.tistory.com/13 상수, 변하지 않는 값 상수(constant) 변하지 않는 값, 변하는 값 변수와 반대 개념이다. https://standout.tistory.co
standout.tistory.com
https://standout.tistory.com/495
Annotation - @NonNull
@NonNull 해당 필드가 null 값을 가질 수 없도록 설정 메소드에서 @NonNull 어노테이션을 사용하여 매개변수가 null이면 예외를 발생시킬 수 있다. import lombok.NonNull; public class Person { private String name; @NonN
standout.tistory.com
'JAVA > Spring' 카테고리의 다른 글
Annotation - @RequestBody @ResponseBody (0) | 2023.05.10 |
---|---|
Annotation - @ResponseEntity (0) | 2023.05.10 |
Annotation - @NonNull (0) | 2023.04.20 |
Annotation - @Data (0) | 2023.04.20 |
Annotation - @AllArgsConstructor (0) | 2023.04.20 |