Interface Persistence<T>
- Type Parameters:
T
- the type of the model class to persist
- All Known Implementing Classes:
DefaultPersistence
public interface Persistence<T>
This interface defines the methods for persistence operations on a given model class.
The creation of rest api using annotation
@REST
is based on this interface to deal with persistence-
Method Summary
Modifier and TypeMethodDescriptionDeletes an existing instance of the model class from the persistence layer.getAll()
Returns a list with all instances of the model class currently persisted.Returns the instance of the model class identified by the given ID.Returns a limited list with instances of the model class currently persisted.Saves a new instance of the model class to the persistence layer.Updates an existing instance of the model class in the persistence layer.
-
Method Details
-
getAll
Returns a list with all instances of the model class currently persisted.- Returns:
- a list with all instances of the model class currently persisted
-
getLimit
Returns a limited list with instances of the model class currently persisted.- Parameters:
limit
- the maximum number of instances to retrieve- Returns:
- a limited list with instances of the model class currently persisted
-
getById
Returns the instance of the model class identified by the given ID.- Parameters:
id
- the ID of the instance to retrieve- Returns:
- the instance of the model class identified by the given ID, or null if not found
-
save
Saves a new instance of the model class to the persistence layer.- Parameters:
t
- the instance of the model class to save- Returns:
- the saved instance of the model class
-
update
Updates an existing instance of the model class in the persistence layer.- Parameters:
t
- the instance of the model class to update- Returns:
- the updated instance of the model class
-
delete
Deletes an existing instance of the model class from the persistence layer.- Parameters:
t
- the instance of the model class to delete- Returns:
- the deleted instance of the model class
-