They are the representation of an object or concept from the real world described in terms of computable data, which can be transmitted through a protocol and stored persistently.
Our models should only store information to represent objects or concepts from the real world and should not be used for other responsibilities.
The library uses classes that implement the Model
interface with a unique identifier of type String
to perform searches, deletions, and updates.
import es.revengenetwork.storage.model.Model;
import org.jetbrains.annotations.NotNull;
public class UserModel implements Model {
private final String id;
private final String name;
private int age;
private Date birthday;
public UserModel(
final @NotNull String id,
final @NotNull String name,
final int age,
final @NotNull Date birthday
) {
this.id = id;
this.name = name;
this.age = age;
this.birthday = birthday;
}
@Override
public @NotNull String id() {
return this.id;
}
public @NotNull String name() {
return this.name;
}
public int age() {
return this.age;
}
public @NotNull Date birthday() {
return this.birthday;
}
}
These models do not require a specific storage format. Just ensure that their attributes can be represented as primitive data types since you will need it later for the serialization process.