public class UserEntity {
private String userId;
private String userPwd;
private String userName;
private int userAge;
public MemberEntity(String userId, String userPwd, String userName, int userAge) {
this.userId = userId;
this.userPwd = userPwd;
this.userName = userName;
this.userAge = userAge;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserPwd() {
return userPwd;
}
public void setUserPwd(String userPwd) {
this.userPwd = userPwd;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getUserAge() {
return userAge;
}
public void setUserAge(int userAge) {
this.userAge = userAge;
}
}
@Getter
@Setter
public class UserEntity {
private String userId;
private String userPwd;
private String userName;
private int userAge;
}
@Getter
@Setter
@Builder
public class UserEntity {
private String userId;
private String userPwd;
private String userName;
private int userAge;
}
[@Builder 존재 안하는 경우]
public class UserNotBuilder {
public void builderTest() {
User user = new User(userId, userPwd, userName, userAge) // 순서대로 작성해야만 함
System.out.println(user);
}
}
[@Builder 존재 하는 경우]
public class UserBuilder {
public void builderTest() {
User user = User.builder() // 순서대로 작성안해도 괜찮음
.userId("test")
.userPwd("test")
.userName("test")
.userAge(20)
.build();
System.out.println(user);
}
}