[lombok] @ToString

hyewon jeong·2022년 12월 23일
0

Spring

목록 보기
5/59
post-thumbnail

toString() 메소드를 자동으로 생성해준다.

exclude : 특정 필드를 toString() 결과에서 제외시킨다.

@ToString(exclude = "pw")
public class Comment {
  private Long id;
  private String name;
  private String content;
  private String pw;
}
Comment comment = new Comment();
comment.setId(1L);
comment.setName("comment1");
comment.setComment("댓글입니다.");
comment.setPw("1234");

System.out.println(comment);
// User(id=1, name=comment1, comment=댓글입니다.)
profile
개발자꿈나무

0개의 댓글