Package org.keycloak.models.map.storage
Interface CrudOperations<V extends AbstractEntity & UpdatableEntity,M>
- Type Parameters:
V
- Type of the value stored in the storageM
- Type of the model object
- All Known Implementing Classes:
ConcurrentHashMapCrudOperations
,FileCrudOperations
,HotRodCrudOperations
,SingleUseObjectConcurrentHashMapCrudOperations
,SingleUseObjectHotRodCrudOperations
public interface CrudOperations<V extends AbstractEntity & UpdatableEntity,M>
Interface for CRUD operations on the storage. The operations may not respect transactional boundaries
if the underlying storage does not support it.
-
Method Summary
Modifier and TypeMethodDescriptionCreates an object in the storage.boolean
Deletes object with the givenkey
from the storage, if exists, no-op otherwise.long
delete
(QueryParameters<M> queryParameters) Deletes objects that match the given criteria.default String
determineKeyFromValue
(V value) Determines first available key from the value upon creation.default boolean
Returnstrue
if the object with the givenkey
exists in the storage.default boolean
exists
(QueryParameters<M> queryParameters) Returnstrue
if at least one object is satisfying givencriteria
from the storage.long
getCount
(QueryParameters<M> queryParameters) Returns the number of objects satisfying givencriteria
from the storage.Returns object with the givenkey
from the storage ornull
if object does not exist.read
(QueryParameters<M> queryParameters) Returns stream of objects satisfying givencriteria
from the storage.Updates the object with the key of thevalue
's ID in the storage if it already exists.
-
Method Details
-
create
Creates an object in the storage.
ID of thevalue
may be prescribed in id of thevalue
. If the id isnull
or 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
value
in the store. It may or may not be the same instance asvalue
- Throws:
NullPointerException
- ifvalue
isnull
- See Also:
-
read
Returns object with the givenkey
from the storage ornull
if object does not exist.
IfV
implementsExpirableEntity
this method should not return entities that are expired. SeeExpirableEntity
JavaDoc for more details. TODO: Consider returningOptional<V>
instead.- Parameters:
key
- Key of the object. Must not benull
.- Returns:
- See description
- Throws:
NullPointerException
- if thekey
isnull
-
update
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 itsid
isnull
- See Also:
-
delete
Deletes object with the givenkey
from the storage, if exists, no-op otherwise.- Parameters:
key
-- Returns:
- Returns
true
if the object has been deleted or result cannot be determined,false
otherwise.
-
delete
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
-1
if not supported)
-
read
Returns stream of objects satisfying givencriteria
from the storage. The criteria are specified in the given criteria builder based on model properties.
IfV
implementsExpirableEntity
this method should not return entities that are expired. SeeExpirableEntity
JavaDoc for more details.- Parameters:
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Stream of objects. Never returns
null
.
-
getCount
Returns the number of objects satisfying givencriteria
from 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
Returnstrue
if the object with the givenkey
exists in the storage.false
otherwise.- Parameters:
key
- Key of the object. Must not benull
.- Returns:
- See description
- Throws:
NullPointerException
- if thekey
isnull
-
exists
Returnstrue
if at least one object is satisfying givencriteria
from the storage.false
otherwise. The criteria are specified in the given criteria builder based on model properties.- Parameters:
queryParameters
- parameters for the query- Returns:
- See description
-
determineKeyFromValue
Determines first available key from the value upon creation.- Parameters:
value
-- Returns:
-