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