Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- springboot jwt example
- Constants pool
- string comparison
- HHH000104
- spring-boot-maven-plugin
- springboot jwt
- mongodb install ec2
- 기본 Manifest 속성이 없습니다
- jvm memory model
- JPA
- angular jwt
- install mongodb docker
- springboot maven plugin
- docker mongodb
- jvm 메모리 구조
- springboot mongodb config
- jwt example
- spring jwt
- intern
- jvm memory structure
- JWT
- jvm 모델
- springboot-angular-jwt
- jwt token
- spring filter ordering
- jpa pagination
- String Constants Pool
- docker mongodb install
- String Pool
- filter ordering
Archives
- Today
- Total
개발블로그
kotlin data class multiple constructor 본문
kotlin의 data class는 기본적으로 constructor, getter, setter를 생성해준다.
따라서 lombok library를 쓰는 것과 같이 루틴한 코드를 생략할 수 있다.
이 때 생성되는 constructor 스펙은 data class에 정의한 모든 field를 주입받는 형태이다.
기본 생성자 스펙 외의 다른 스펙의 생성자를 두고 싶다면 다음과 같이 정의한다.
data class ResponseEntity<T>(
val code : Int
,var message: String?
,var payload: T?){
constructor(code: Int) : this(code, "", null)
constructor(code: Int, message: String?) : this(code , message, null)
constructor(code: Int, payload: T?) : this(code, "", payload)
}
별도 생성자를 정의하더라도 기본 생성자 스펙은 중복 정의하지 말아야 한다. (기본 생성자 스펙 정의시 에러난다)
Comments