반응형
- 사전준비 : 롬복 활성화 하기
어노테이션 사용
package com.example.practice5.lombok.model;
import lombok.*;
import org.springframework.web.util.pattern.PathPattern;
import java.time.LocalDateTime;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@RequiredArgsConstructor
@ToString
public class User {
@NonNull
private String name;
@NonNull
private String email;
private LocalDateTime createAt;
private LocalDateTime updateAt;
}
어노테이션 사용 안할 때 (Delombok 했을때)
package com.example.practice5.lombok.model;
import lombok.NonNull;
import java.time.LocalDateTime;
public class User {
@NonNull
private String name;
@NonNull
private String email;
private LocalDateTime createAt;
private LocalDateTime updateAt;
public User(@NonNull String name, @NonNull String email) {
this.name = name;
this.email = email;
}
public User(@NonNull String name, @NonNull String email, LocalDateTime createAt, LocalDateTime updateAt) {
this.name = name;
this.email = email;
this.createAt = createAt;
this.updateAt = updateAt;
}
public User() {
}
public @NonNull String getName() {
return this.name;
}
public @NonNull String getEmail() {
return this.email;
}
public LocalDateTime getCreateAt() {
return this.createAt;
}
public LocalDateTime getUpdateAt() {
return this.updateAt;
}
public void setName(@NonNull String name) {
this.name = name;
}
public void setEmail(@NonNull String email) {
this.email = email;
}
public void setCreateAt(LocalDateTime createAt) {
this.createAt = createAt;
}
public void setUpdateAt(LocalDateTime updateAt) {
this.updateAt = updateAt;
}
public String toString() {
return "User(name=" + this.getName() + ", email=" + this.getEmail() + ", createAt=" + this.getCreateAt() + ", updateAt=" + this.getUpdateAt() + ")";
}
}
반응형
'Spring' 카테고리의 다른 글
[스프링] Lombok - @Data (0) | 2023.07.07 |
---|---|
[스프링] Lombok - @Builder (0) | 2023.07.07 |
[스프링] banner 변경 (0) | 2023.07.07 |
[스프링] interceptor (0) | 2023.07.06 |
[스프링] AOP (0) | 2023.07.06 |