Java class (used as a Data Transfer Object):
class Resource also has a field named id
with a different type along with its getter and setter, hence the syntax error.
class A extends Resource
{
private int id;
public int getId() { return id; } // syntax error as getId() function already exists in Resource
public void setId(int id) { this.id = id; }
}
Since the above class is a DTO, a JSON response (with field id
) will be mapped to it, and getId() cannot be used, I want to change the field to _id_
and change getter and setter correspondingly, and mark it with an annotation saying bind this to id
field.
Note: I'm using spring boot. I tried using @JsonProperty annotation but that didn't work. Is there an annotation for doing this in spring?