Package expert.os.harperdb
Interface Template
public interface Template
A template interface for generic data manipulation operations.
-
Method Summary
Modifier and TypeMethodDescription<K,T> boolean Deletes an entity by its identifier and type from the data store.<K> booleanDeletes an entity by its identifier from the data store.<K,T> boolean deleteAllById(Class<T> type, Iterable<K> ids) Deletes multiple entities by their identifiers and type from the data store.<K> booleandeleteAllById(String table, Iterable<K> ids) Deletes multiple entities by their identifiers and table from the data store.<K,T> List <T> findAllById(Class<T> type, Iterable<K> ids) Finds multiple entities by their identifiers and type in the data store.<K,T> Optional <T> Finds an entity by its identifier and type in the data store.<T> booleanInserts multiple entities into the data store.<T> booleaninsert(T entity) Inserts a single entity into the data store.<T> booleanUpdates multiple entities in the data store.<T> booleanupdate(T entity) Updates a single entity in the data store.<T> booleanUpserts (inserts or updates) multiple entities into the data store.<T> booleanupsert(T entity) Upserts (inserts or updates) a single entity into the data store.
-
Method Details
-
insert
<T> boolean insert(T entity) Inserts a single entity into the data store.- Type Parameters:
T- The type of the entity.- Parameters:
entity- The entity to be inserted.- Returns:
- true if the insertion is successful; false otherwise.
- Throws:
NullPointerException- if the provided entity is null.
-
insert
Inserts multiple entities into the data store.- Type Parameters:
T- The type of the entities.- Parameters:
entities- The entities to be inserted.- Returns:
- true if the insertion is successful; false otherwise.
- Throws:
NullPointerException- if the provided entities is null.
-
update
<T> boolean update(T entity) Updates a single entity in the data store.- Type Parameters:
T- The type of the entity.- Parameters:
entity- The entity to be updated.- Returns:
- true if the update is successful; false otherwise.
- Throws:
NullPointerException- if the provided entity is null.
-
update
Updates multiple entities in the data store.- Type Parameters:
T- The type of the entities.- Parameters:
entities- The entities to be updated.- Returns:
- true if the update is successful; false otherwise.
- Throws:
NullPointerException- if the provided entities is null.
-
upsert
<T> boolean upsert(T entity) Upserts (inserts or updates) a single entity into the data store.- Type Parameters:
T- The type of the entity.- Parameters:
entity- The entity to be upserted.- Returns:
- true if the upsert is successful; false otherwise.
- Throws:
NullPointerException- if the provided entity is null.
-
upsert
Upserts (inserts or updates) multiple entities into the data store.- Type Parameters:
T- The type of the entities.- Parameters:
entities- The entities to be upserted.- Returns:
- true if the upsert is successful; false otherwise.
- Throws:
NullPointerException- if the provided entities is null.
-
delete
Deletes an entity by its identifier from the data store.- Type Parameters:
K- The type of the identifier.- Parameters:
table- The table or entity type associated with the data. If provided as a Class or instance, it takes the simple name of the class in lowercase.id- The identifier of the entity to be deleted.- Returns:
- true if the deletion is successful; false otherwise.
- Throws:
NullPointerException- if the provided table or id is null.
-
delete
Deletes an entity by its identifier and type from the data store.- Type Parameters:
K- The type of the identifier.T- The type of the entity.- Parameters:
type- The class representing the entity type. It takes the simple name of the class in lowercase.id- The identifier of the entity to be deleted.- Returns:
- true if the deletion is successful; false otherwise.
- Throws:
NullPointerException- if the provided type or id is null.
-
deleteAllById
Deletes multiple entities by their identifiers and type from the data store.- Type Parameters:
K- The type of the identifier.T- The type of the entity.- Parameters:
type- The class representing the entity type. It takes the simple name of the class in lowercase.ids- The identifiers of the entities to be deleted.- Returns:
- true if the deletion is successful; false otherwise.
- Throws:
NullPointerException- if the provided type or ids is null.
-
deleteAllById
Deletes multiple entities by their identifiers and table from the data store.- Type Parameters:
K- The type of the identifier.- Parameters:
table- The table or entity type associated with the data. If provided as a Class or instance, it takes the simple name of the class in lowercase.ids- The identifiers of the entities to be deleted.- Returns:
- true if the deletion is successful; false otherwise.
- Throws:
NullPointerException- if the provided table or ids is null.
-
findById
Finds an entity by its identifier and type in the data store.- Type Parameters:
K- The type of the identifier.T- The type of the entity.- Parameters:
type- The class representing the entity type. It takes the simple name of the class in lowercase.id- The identifier of the entity to be retrieved.- Returns:
- an Optional containing the entity if found, or an empty Optional otherwise.
- Throws:
NullPointerException- if the provided id or type is null.
-
findAllById
Finds multiple entities by their identifiers and type in the data store.- Type Parameters:
K- The type of the identifier.T- The type of the entity.- Parameters:
type- The class representing the entity type. It takes the simple name of the class in lowercase.ids- The identifiers of the entities to be retrieved.- Returns:
- a List containing the retrieved entities.
- Throws:
NullPointerException- if the provided ids or type is null.
-