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 | 31 |
Tags
- springboot jwt
- Constants pool
- jpa pagination
- jwt token
- spring-boot-maven-plugin
- intern
- mongodb install ec2
- angular jwt
- spring jwt
- jvm 메모리 구조
- jvm 모델
- filter ordering
- jvm memory model
- springboot mongodb config
- JWT
- jvm memory structure
- 기본 Manifest 속성이 없습니다
- jwt example
- docker mongodb
- spring filter ordering
- HHH000104
- JPA
- string comparison
- String Constants Pool
- String Pool
- docker mongodb install
- springboot jwt example
- springboot-angular-jwt
- install mongodb docker
- springboot maven plugin
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