Data class where i need to set values for different fields at different times I am creating a request for an api using below class-

class ABCDRequest {

    @JsonProperty("name")
    private var name: String? = null

    @JsonProperty("question")
    private var question: String? = null

    @JsonProperty("ans")
    private var ans: String? = null

    fun getName(): String? {
        return name
    }

    fun setName(userName: String?) {
        this.name = userName
    }

    fun getQuestion(): String? {
        return question
    }

    fun setQuestion(ques: String?) {
        this.question = ques
    }

    fun getAns(): String? {
        return ans
    }

    fun setAns(answer: String?) {
        this.ans = answer
    }

}


I need both setter and getter methods and i need to set values for different fields at different times(not at time time of creation of object for this class).

Is the above way idle or is there any 1 or few lines code for this in kotlin?
Use Data Class which automatically generates field accessors, hashCode(), equals(), toString() and other methods. Read this for a quick introduction. 

data class ABCDRequest (
    @JsonProperty("name")
    private var name: String? = null,
    @JsonProperty("question")
    private var question: String? = null,
    @JsonProperty("ans")
    private var ans: String? = null
)


For the official documentation on Data Class, head over to this link.