@NonNull
해당 필드가 null 값을 가질 수 없도록 설정
메소드에서 @NonNull 어노테이션을 사용하여
매개변수가 null이면 예외를 발생시킬 수 있다.
import lombok.NonNull;
public class Person {
private String name;
@NonNull
private int age;
public Person(String name, @NonNull int age) {
this.name = name;
this.age = age;
}
public void setName(String name) {
this.name = name;
}
public void setAge(@NonNull int age) {
this.age = age;
}
}
https://standout.tistory.com/28
null이란?
NullPointerException 값이 없음을 나타내는 자바스크립트의 데이터 타입 중 하나. "의도적으로 값이 없음"을 나타내는 특별한 값 null은 빈 문자열("")이나 숫자 0과는 다른 개념으로, '값이 없음' 을 나
standout.tistory.com
'JAVA > Spring' 카테고리의 다른 글
Annotation - @ResponseEntity (0) | 2023.05.10 |
---|---|
Annotation - @RequiredArgsConstructor (0) | 2023.04.20 |
Annotation - @Data (0) | 2023.04.20 |
Annotation - @AllArgsConstructor (0) | 2023.04.20 |
Annotation - @EqualsAndHashCode (0) | 2023.04.20 |