-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathEntity.java
More file actions
31 lines (25 loc) · 1.08 KB
/
Entity.java
File metadata and controls
31 lines (25 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package solutions.bellatrix.data.http.infrastructure;
import lombok.experimental.SuperBuilder;
import solutions.bellatrix.data.configuration.RepositoryFactory;
import solutions.bellatrix.data.contracts.Repository;
@SuperBuilder
@SuppressWarnings("unchecked")
public abstract class Entity<TIdentifier, TEntity> {
public TEntity get() {
var repository = (Repository<Entity>)RepositoryFactory.INSTANCE.getRepository(this.getClass());
return (TEntity)repository.getById(this);
}
public TEntity create() {
var repository = (Repository<Entity>)RepositoryFactory.INSTANCE.getRepository(this.getClass());
return (TEntity)repository.create(this);
}
public TEntity update() {
var repository = (Repository<Entity>)RepositoryFactory.INSTANCE.getRepository(this.getClass());
return (TEntity)repository.update(this);
}
public void delete() {
var repository = (Repository<Entity>)RepositoryFactory.INSTANCE.getRepository(this.getClass());
repository.delete(this);
}
public abstract TIdentifier getIdentifier();
}