Package org.springframework.data.map
Class MapKeyValueAdapter
java.lang.Object
org.springframework.data.keyvalue.core.AbstractKeyValueAdapter
org.springframework.data.map.MapKeyValueAdapter
- All Implemented Interfaces:
DisposableBean
,KeyValueAdapter
KeyValueAdapter
implementation for Map
.- Author:
- Christoph Strobl, Derek Cochran, Marcel Overdijk
-
Constructor Summary
ConstructorsConstructorDescriptionCreate newMapKeyValueAdapter
usingConcurrentHashMap
as backing store type.MapKeyValueAdapter
(Class<? extends Map> mapType) Creates a newMapKeyValueAdapter
using the givenMap
as backing store.MapKeyValueAdapter
(Class<? extends Map> mapType, QueryEngine<? extends KeyValueAdapter, ?, ?> engine) Creates a newMapKeyValueAdapter
using the givenMap
as backing store and query engine.MapKeyValueAdapter
(Class<? extends Map> mapType, SortAccessor<Comparator<?>> sortAccessor) Creates a newMapKeyValueAdapter
using the givenMap
as backing store.Create new instance ofMapKeyValueAdapter
using given dataStore for persistence.MapKeyValueAdapter
(Map<String, Map<Object, Object>> store, QueryEngine<? extends KeyValueAdapter, ?, ?> engine) Create new instance ofMapKeyValueAdapter
using given dataStore for persistence and query engine.MapKeyValueAdapter
(QueryEngine<? extends KeyValueAdapter, ?, ?> engine) Create newMapKeyValueAdapter
using the given query engine. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all objects.boolean
Check if a object with given id exists in keyspace.long
Count number of objects within keyspace.@Nullable Object
Delete and return the object with given type and id.void
deleteAllOf
(String keyspace) Remove all objects of given type.void
destroy()
Returns aCloseableIterator
that iterates over all entries.@Nullable Object
Get the object with given id from keyspace.Get all elements for given keyspace.getKeySpaceMap
(String keyspace) Get map associated with given key space.@Nullable Object
Add object with given id to keyspace.Methods inherited from class org.springframework.data.keyvalue.core.AbstractKeyValueAdapter
count, delete, find, find, get, getQueryEngine
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.keyvalue.core.KeyValueAdapter
entries, exists, getAllOf
-
Constructor Details
-
MapKeyValueAdapter
public MapKeyValueAdapter()Create newMapKeyValueAdapter
usingConcurrentHashMap
as backing store type. -
MapKeyValueAdapter
Create newMapKeyValueAdapter
using the given query engine.- Parameters:
engine
- the query engine.- Since:
- 2.4
-
MapKeyValueAdapter
Creates a newMapKeyValueAdapter
using the givenMap
as backing store.- Parameters:
mapType
- must not be null.
-
MapKeyValueAdapter
Creates a newMapKeyValueAdapter
using the givenMap
as backing store.- Parameters:
mapType
- must not be null.sortAccessor
- accessor granting access to sorting implementation- Since:
- 3.1.10
-
MapKeyValueAdapter
public MapKeyValueAdapter(Class<? extends Map> mapType, QueryEngine<? extends KeyValueAdapter, ?, ?> engine) Creates a newMapKeyValueAdapter
using the givenMap
as backing store and query engine.- Parameters:
mapType
- must not be null.engine
- the query engine.- Since:
- 2.4
-
MapKeyValueAdapter
Create new instance ofMapKeyValueAdapter
using given dataStore for persistence.- Parameters:
store
- must not be null.
-
MapKeyValueAdapter
public MapKeyValueAdapter(Map<String, Map<Object, Object>> store, QueryEngine<? extends KeyValueAdapter, ?, ?> engine) Create new instance ofMapKeyValueAdapter
using given dataStore for persistence and query engine.- Parameters:
store
- must not be null.engine
- the query engine.- Since:
- 2.4
-
-
Method Details
-
put
Description copied from interface:KeyValueAdapter
Add object with given id to keyspace.- Parameters:
id
- must not be null.keyspace
- must not be null.- Returns:
- the item previously associated with the id.
-
contains
Description copied from interface:KeyValueAdapter
Check if a object with given id exists in keyspace.- Parameters:
id
- must not be null.keyspace
- must not be null.- Returns:
- true if item of type with id exists.
-
count
Description copied from interface:KeyValueAdapter
Count number of objects within keyspace.- Parameters:
keyspace
- must not be null.- Returns:
-
get
Description copied from interface:KeyValueAdapter
Get the object with given id from keyspace.- Parameters:
id
- must not be null.keyspace
- must not be null.- Returns:
- null in case no matching item exists.
-
delete
Description copied from interface:KeyValueAdapter
Delete and return the object with given type and id.- Parameters:
id
- must not be null.keyspace
- must not be null.- Returns:
- null if object could not be found
-
getAllOf
Description copied from interface:KeyValueAdapter
Get all elements for given keyspace.- Parameters:
keyspace
- must not be null.- Returns:
- empty
Collection
if nothing found.
-
entries
Description copied from interface:KeyValueAdapter
Returns aCloseableIterator
that iterates over all entries.- Parameters:
keyspace
- must not be null.- Returns:
-
deleteAllOf
Description copied from interface:KeyValueAdapter
Remove all objects of given type.- Parameters:
keyspace
- must not be null.
-
clear
public void clear()Description copied from interface:KeyValueAdapter
Removes all objects. -
destroy
- Throws:
Exception
-
getKeySpaceMap
Get map associated with given key space.- Parameters:
keyspace
- must not be null.- Returns:
-