티스토리 뷰
반응형
package com.demo.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor // 모든 생성자
@NoArgsConstructor // 빈 생성자
@Data // getter, setter, ToString
public class AccntInfo {
String cstmrCode;
String accnt;
String createdAt;
long blce;
public AccntInfo cSetCstmrCode(String cstmrCode) {
this.cstmrCode = cstmrCode;
return this;
}
public AccntInfo cSetAccnt(String accnt) {
this.accnt = accnt;
return this;
}
public AccntInfo cSetCreatedAt(String createdAt) {
this.createdAt = createdAt;
return this;
}
public AccntInfo cSetBlce(long blce) {
this.blce = blce;
return this;
}
}
package com.demo;
import com.demo.domain.AccntInfo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
new AccntInfo().cSetAccnt("asdasd").cSetBlce(1234L);
}
}
이렇게 쓰면 한줄로 체인처럼 메서드를 호출할 수 있기에 가독성을 높인다.
반응형
'SpringBoot' 카테고리의 다른 글
| [Design Pattern]Adapter Pattern (0) | 2021.08.08 |
|---|---|
| [Design Pattern]Singleton Pattern (0) | 2021.08.08 |
| DTO,VO.DAO에 대해서 (0) | 2021.08.06 |
| [SQL]파라미터를 다시 리턴 하는 Query (0) | 2021.08.05 |
| Spring-Mapper파일 mapUnderscoreToCamelCase에 관해 (0) | 2021.08.04 |
