I declared a class with annotation @Data
and declared custom setter.
However, it doesn't happened called setter method.
Here is for build data.
// Build data from json string.
Type typeOfResultSet = new TypeToken<JsonResult<AntTalkList>>(){}.getType();
Gson g = new Gson();
JsonResult<AntTalkList> res = g.fromJson(jsonString, typeOfResultSet);
And this is lombok @Data
anotition added class.
@Data
public class TalkInfo {
private long articleId;
private long userId;
private String userName; // this needs custom setter
private String userType;
private int last_c_seq ;
private String title;
private String question;
private String dateInfo;
private int replyCount;
private String thumbUrl;
public void setUserName(String userName){ // I want to call this.
try{
//This doesn't printed out
System.out.println("userName");
this.userName = URLDecoder.decode(userName, "UTF-8");
} catch(Exception e){
e.printStackTrace();
this.userName = userName;
}
}
I don't know how to solve this problem.
Maybe is there any relations using Gson
?