public class ConcurrentHashMapStorage<K,V extends AbstractEntity<K>,M> extends Object implements MapStorage<K,V,M>
| Constructor and Description |
|---|
ConcurrentHashMapStorage(Class<M> modelClass,
StringKeyConvertor<K> keyConvertor) |
| Modifier and Type | Method and Description |
|---|---|
V |
create(K key,
V value)
Creates an object in the store identified by given
key. |
ModelCriteriaBuilder<M> |
createCriteriaBuilder()
Returns criteria builder for the storage engine.
|
MapKeycloakTransaction<K,V,M> |
createTransaction(KeycloakSession session)
Creates a
MapKeycloakTransaction object that tracks a new transaction related to this storage. |
boolean |
delete(K key)
Deletes object with the given
key from the storage, if exists, no-op otherwise. |
long |
delete(ModelCriteriaBuilder<M> criteria)
Deletes objects that match the given criteria.
|
long |
getCount(ModelCriteriaBuilder<M> criteria)
Returns the number of objects satisfying given
criteria from the storage. |
StringKeyConvertor<K> |
getKeyConvertor()
Returns a
StringKeyConvertor that is used to convert primary keys
from String to internal representation and vice versa. |
V |
read(K key)
Returns object with the given
key from the storage or null if object does not exist. |
Stream<V> |
read(ModelCriteriaBuilder<M> criteria)
Returns stream of objects satisfying given
criteria from the storage. |
V |
update(K key,
V value)
Updates the object with the given
id in the storage if it already exists. |
public ConcurrentHashMapStorage(Class<M> modelClass, StringKeyConvertor<K> keyConvertor)
public V create(K key, V value)
MapStoragekey.create in interface MapStorage<K,V extends AbstractEntity<K>,M>key - Key of the object as seen in the logical levelvalue - Entitypublic V read(K key)
MapStoragekey from the storage or null if object does not exist.
Optional<V> instead.read in interface MapStorage<K,V extends AbstractEntity<K>,M>key - Key of the object. Must not be null.public V update(K key, V value)
MapStorageid in the storage if it already exists.update in interface MapStorage<K,V extends AbstractEntity<K>,M>key - Primary key of the object to updatevalue - Updated valuepublic boolean delete(K key)
MapStoragekey from the storage, if exists, no-op otherwise.delete in interface MapStorage<K,V extends AbstractEntity<K>,M>true if the object has been deleted or result cannot be determined, false otherwise.public long delete(ModelCriteriaBuilder<M> criteria)
MapStoragedelete in interface MapStorage<K,V extends AbstractEntity<K>,M>-1 if not supported)public ModelCriteriaBuilder<M> createCriteriaBuilder()
MapStoragecreateCriteriaBuilder in interface MapStorage<K,V extends AbstractEntity<K>,M>nullpublic MapKeycloakTransaction<K,V,M> createTransaction(KeycloakSession session)
MapStorageMapKeycloakTransaction 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<K,V extends AbstractEntity<K>,M>nullpublic StringKeyConvertor<K> getKeyConvertor()
MapStorageStringKeyConvertor that is used to convert primary keys
from String to internal representation and vice versa.getKeyConvertor in interface MapStorage<K,V extends AbstractEntity<K>,M>null.public Stream<V> read(ModelCriteriaBuilder<M> criteria)
MapStoragecriteria from the storage.
The criteria are specified in the given criteria builder based on model properties.read in interface MapStorage<K,V extends AbstractEntity<K>,M>criteria - Criteria filtering out the object, originally obtained
from MapStorage.createCriteriaBuilder() method of this object.
If null, it returns an empty stream.null.public long getCount(ModelCriteriaBuilder<M> criteria)
MapStoragecriteria from the storage.
The criteria are specified in the given criteria builder based on model properties.getCount in interface MapStorage<K,V extends AbstractEntity<K>,M>null.Copyright © 2021 JBoss by Red Hat. All rights reserved.