Here is the class
package com.bablo.domain;
import com.google.gson.annotation.SerializedName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter @Setter
@ToString
public class PC {
@SerializeName("name")
private String name;
@SerializeName("model")
private String model;
@SerializeName("processor")
private String processor;
}
In the above class attribute for model can have an empty string in the json, how to give it default value at the time of serialization and deserialization.
That is in the requestbody json the value for the model key can have empty string as a value, how to read it and put instead default values in the place of empty string in the class attribute.
Should I disable lombok and add custom getter and setter methods in my class to override the default values?
Or is there any annotation available in Gson to achieve this?
Or lombok has some workaround to achieve this?