Question Similarity i.e. this is not a duplicate
N.B: there are a number of questions which seem similar to this one:
What is the exact meaning of the JPA @Entity annotation?
What is an Entity? Why is it called Entity?
But they either refer to the 'Entity Framework' or the '@Entity' annotation (which is apparently used to stated that a class can be mapped to a table). Although my question may appear similar to these it is slightly different and so should not be considered a duplicate.
My actual question
I am working with a codebase which has a package called 'com.xxx.yyy.entities'. This package contains a number of classes all with essentially the same structure:
- private fields
- public getters for each private field
- public setters for each private field
- a 'toString' method.
An example of one of the simplest classes is below:
public class Competition {
private String id;
private String name;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String toString() {
return "{" + "" + "id=" + getId() + "," + "name=" + getName() + "}";
}
}
The classes contained within the 'entities' package are never actually instantiated but instead are always serialised/deserialised to/from JSON (this particular project uses GSON to achieve this).
My questions are:
- what exactly does 'entity' mean here?
- Does it basically just mean a class which is intended to be serialised to/from JSON? Is there not a more concrete term for this rather than the extremely generic 'entity'?
- Is this a common pattern within Java projects?