Class MapKeyValueAdapter

All Implemented Interfaces:
DisposableBean, KeyValueAdapter

public class MapKeyValueAdapter extends AbstractKeyValueAdapter
KeyValueAdapter implementation for Map.
Author:
Christoph Strobl, Derek Cochran, Marcel Overdijk
  • Constructor Details

    • MapKeyValueAdapter

      public MapKeyValueAdapter()
      Create new MapKeyValueAdapter using ConcurrentHashMap as backing store type.
    • MapKeyValueAdapter

      public MapKeyValueAdapter(QueryEngine<? extends KeyValueAdapter,?,?> engine)
      Create new MapKeyValueAdapter using the given query engine.
      Parameters:
      engine - the query engine.
      Since:
      2.4
    • MapKeyValueAdapter

      public MapKeyValueAdapter(Class<? extends Map> mapType)
      Creates a new MapKeyValueAdapter using the given Map as backing store.
      Parameters:
      mapType - must not be null.
    • MapKeyValueAdapter

      public MapKeyValueAdapter(Class<? extends Map> mapType, SortAccessor<Comparator<?>> sortAccessor)
      Creates a new MapKeyValueAdapter using the given Map 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 new MapKeyValueAdapter using the given Map as backing store and query engine.
      Parameters:
      mapType - must not be null.
      engine - the query engine.
      Since:
      2.4
    • MapKeyValueAdapter

      public MapKeyValueAdapter(Map<String,Map<Object,Object>> store)
      Create new instance of MapKeyValueAdapter 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 of MapKeyValueAdapter using given dataStore for persistence and query engine.
      Parameters:
      store - must not be null.
      engine - the query engine.
      Since:
      2.4
  • Method Details

    • put

      public Object put(Object id, Object item, String keyspace)
      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

      public boolean contains(Object id, String keyspace)
      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

      public long count(String keyspace)
      Description copied from interface: KeyValueAdapter
      Count number of objects within keyspace.
      Parameters:
      keyspace - must not be null.
      Returns:
    • get

      public Object get(Object id, String keyspace)
      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

      public Object delete(Object id, String keyspace)
      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

      public Collection<?> getAllOf(String keyspace)
      Description copied from interface: KeyValueAdapter
      Get all elements for given keyspace.
      Parameters:
      keyspace - must not be null.
      Returns:
      empty Collection if nothing found.
    • entries

      public CloseableIterator<Map.Entry<Object,Object>> entries(String keyspace)
      Description copied from interface: KeyValueAdapter
      Returns a CloseableIterator that iterates over all entries.
      Parameters:
      keyspace - must not be null.
      Returns:
    • deleteAllOf

      public void deleteAllOf(String keyspace)
      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

      public void destroy() throws Exception
      Throws:
      Exception
    • getKeySpaceMap

      protected Map<Object,Object> getKeySpaceMap(String keyspace)
      Get map associated with given key space.
      Parameters:
      keyspace - must not be null.
      Returns: