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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description V
create(V value)
Creates an object in the storage.boolean
delete(String key)
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, boolean forCreate)
Determines first available key from the value upon creation.default boolean
exists(String key)
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.V
read(String key)
Returns object with the givenkey
from the storage ornull
if object does not exist.Stream<V>
read(QueryParameters<M> queryParameters)
Returns stream of objects satisfying givencriteria
from the storage.V
update(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 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:
AbstractEntity.getId()
-
read
V read(String key)
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
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 itsid
isnull
- See Also:
AbstractEntity.getId()
-
delete
boolean delete(String key)
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
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
-1
if not supported)
-
read
Stream<V> read(QueryParameters<M> queryParameters)
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
long getCount(QueryParameters<M> queryParameters)
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
default boolean exists(String key)
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
default boolean exists(QueryParameters<M> queryParameters)
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
-
-