Interface ConcurrentHashMapCrudOperations<V extends AbstractEntity & UpdatableEntity,M>
-
- All Known Implementing Classes:
ConcurrentHashMapStorage,FileMapStorage.Crud,HotRodMapStorage,SingleUseObjectConcurrentHashMapStorage,SingleUseObjectHotRodMapStorage
public interface ConcurrentHashMapCrudOperations<V extends AbstractEntity & UpdatableEntity,M>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Vcreate(V value)Creates an object in the store.booleandelete(String key)Deletes object with the givenkeyfrom the storage, if exists, no-op otherwise.longdelete(QueryParameters<M> queryParameters)Deletes objects that match the given criteria.default StringdetermineKeyFromValue(V value, boolean forCreate)Determines first available key from the value upon creation.default booleanexists(String key)Returnstrueif the object with the givenkeyexists in the storage.default booleanexists(QueryParameters<M> queryParameters)Returnstrueif at least one object is satisfying givencriteriafrom the storage.longgetCount(QueryParameters<M> queryParameters)Returns the number of objects satisfying givencriteriafrom the storage.Vread(String key)Returns object with the givenkeyfrom the storage ornullif object does not exist.Stream<V>read(QueryParameters<M> queryParameters)Returns stream of objects satisfying givencriteriafrom the storage.Vupdate(V value)Updates the object with the key of thevalue's ID in the storage if it already exists.
-
-
-
Method Detail
-
create
V create(V value)
Creates an object in the store. ID of thevaluemay be prescribed in id of thevalue. If the id isnullor its format is not matching the store internal format for ID, then thevalue's ID will be generated and returned in the id of the return value.- Parameters:
value- Entity to create in the store- Returns:
- Entity representing the
valuein the store. It may or may not be the same instance asvalue - Throws:
NullPointerException- ifvalueisnull- See Also:
AbstractEntity.getId()
-
read
V read(String key)
Returns object with the givenkeyfrom the storage ornullif object does not exist.
IfVimplementsExpirableEntitythis method should not return entities that are expired. SeeExpirableEntityJavaDoc for more details. TODO: Consider returningOptional<V>instead.- Parameters:
key- Key of the object. Must not benull.- Returns:
- See description
- Throws:
NullPointerException- if thekeyisnull
-
update
V update(V value)
Updates the object with the key of thevalue's ID in the storage if it already exists.- Parameters:
value- Updated value- Returns:
- the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)
- Throws:
NullPointerException- if the object or itsidisnull- See Also:
AbstractEntity.getId()
-
delete
boolean delete(String key)
Deletes object with the givenkeyfrom the storage, if exists, no-op otherwise.- Parameters:
key-- Returns:
- Returns
trueif the object has been deleted or result cannot be determined,falseotherwise.
-
delete
long delete(QueryParameters<M> queryParameters)
Deletes objects that match the given criteria.- Parameters:
queryParameters- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Number of removed objects (might return
-1if not supported)
-
read
Stream<V> read(QueryParameters<M> queryParameters)
Returns stream of objects satisfying givencriteriafrom the storage. The criteria are specified in the given criteria builder based on model properties. IfVimplementsExpirableEntitythis method should not return entities that are expired. SeeExpirableEntityJavaDoc for more details.- Parameters:
queryParameters- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Stream of objects. Never returns
null.
-
getCount
long getCount(QueryParameters<M> queryParameters)
Returns the number of objects satisfying givencriteriafrom the storage. The criteria are specified in the given criteria builder based on model properties.- Parameters:
queryParameters- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Number of objects. Never returns
null.
-
exists
default boolean exists(String key)
Returnstrueif the object with the givenkeyexists in the storage.falseotherwise.- Parameters:
key- Key of the object. Must not benull.- Returns:
- See description
- Throws:
NullPointerException- if thekeyisnull
-
exists
default boolean exists(QueryParameters<M> queryParameters)
Returnstrueif at least one object is satisfying givencriteriafrom the storage.falseotherwise. The criteria are specified in the given criteria builder based on model properties.- Parameters:
queryParameters- parameters for the query- Returns:
- See description
-
-