I have a Kotlin data class which takes the parameters as below and parcelable. I have defined a secondary constructor within this data class with two additional parameters lastSeen and netTotal. But, I keep getting the error There's a cycle in the delegation calls chain for the secondary constructor. How do I resolve this?
@Parcelize
data class Person(
val email: Email,
val overrideEmail: Email,
val phone: String,
val firstName: String,
val overrideFirstName: String,
val lastName: String,
val overrideLastName: String,
val personId: String
) : Parcelable {
//some code
constructor(
email: Email,
overrideEmail: Email,
phone: String,
firstName: String,
overrideFirstName: String,
lastName: String,
overrideLastName: String,
personId: String,
lastSeen: String,
netTotal: Int?
) : this(email, overrideEmail, phone, firstName, overrideFirstName, lastName, overrideLastName, personId, lastSeen, netTotal)
}
Additionally I have to use this secondary constructor in a response mapper. The mapper with the original values are shown below. How would I include the secondary constructor in my response mapper?
class PersonFromResponseMapper @Inject constructor() : Mapper<Person, PersonResponse>() {
override fun map(from: PersonResponse, params: Any?): Person = with(from) {
Person(
Email(receiptEmailAddress.orEmpty()),
Email(overrideEmail.orEmpty()),
"",
firstName.orEmpty(),
overrideFirstName.orEmpty(),
lastName.orEmpty(),
overrideLastName.orEmpty(),
personUserId.orEmpty()
)
}