public class ConcurrentHashMapStorage<K,V extends AbstractEntity & UpdatableEntity,M> extends Object implements MapStorage<V,M>
Constructor and Description |
---|
ConcurrentHashMapStorage(Class<M> modelClass,
StringKeyConvertor<K> keyConvertor) |
Modifier and Type | Method and Description |
---|---|
V |
create(V value)
Creates an object in the store.
|
ModelCriteriaBuilder<M> |
createCriteriaBuilder()
Returns criteria builder for the storage engine.
|
MapKeycloakTransaction<V,M> |
createTransaction(KeycloakSession session)
Creates a
MapKeycloakTransaction object that tracks a new transaction related to this storage. |
long |
delete(QueryParameters<M> queryParameters)
Deletes objects that match the given criteria.
|
boolean |
delete(String key)
Deletes object with the given
key from the storage, if exists, no-op otherwise. |
long |
getCount(QueryParameters<M> queryParameters)
Returns the number of objects satisfying given
criteria from the storage. |
StringKeyConvertor<K> |
getKeyConvertor() |
Stream<V> |
read(QueryParameters<M> queryParameters)
Returns stream of objects satisfying given
criteria from the storage. |
V |
read(String key)
Returns object with the given
key from the storage or null if object does not exist. |
V |
update(V value)
Updates the object with the key of the
value 's ID in the storage if it already exists. |
public ConcurrentHashMapStorage(Class<M> modelClass, StringKeyConvertor<K> keyConvertor)
public V create(V value)
MapStorage
value
may be prescribed in id of the value
.
If the id is null
or its format is not matching the store internal format for ID, then
the value
's ID will be generated and returned in the id of the return value.create
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
value
- Entity to create in the storevalue
in the store. It may or may not be the same instance as value
AbstractEntity.getId()
public V read(String key)
MapStorage
key
from the storage or null
if object does not exist.
Optional<V>
instead.read
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
key
- Key of the object. Must not be null
.public V update(V value)
MapStorage
value
's ID in the storage if it already exists.update
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
value
- Updated valueAbstractEntity.getId()
public boolean delete(String key)
MapStorage
key
from the storage, if exists, no-op otherwise.delete
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
true
if the object has been deleted or result cannot be determined, false
otherwise.public long delete(QueryParameters<M> queryParameters)
MapStorage
delete
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.-1
if not supported)public ModelCriteriaBuilder<M> createCriteriaBuilder()
MapStorage
createCriteriaBuilder
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
null
public MapKeycloakTransaction<V,M> createTransaction(KeycloakSession session)
MapStorage
MapKeycloakTransaction
object that tracks a new transaction related to this storage.
In case of JPA or similar, the transaction object might be supplied by the container (via JTA) or
shared same across storages accessing the same database within the same session; in other cases
(e.g. plain map) a separate transaction handler might be created per each storage.createTransaction
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
null
public StringKeyConvertor<K> getKeyConvertor()
public Stream<V> read(QueryParameters<M> queryParameters)
MapStorage
criteria
from the storage.
The criteria are specified in the given criteria builder based on model properties.read
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.null
.public long getCount(QueryParameters<M> queryParameters)
MapStorage
criteria
from the storage.
The criteria are specified in the given criteria builder based on model properties.getCount
in interface MapStorage<V extends AbstractEntity & UpdatableEntity,M>
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.null
.Copyright © 2021 JBoss by Red Hat. All rights reserved.