Interface KeyValueAdapter

All Superinterfaces:
DisposableBean
All Known Implementing Classes:
AbstractKeyValueAdapter, MapKeyValueAdapter

public interface KeyValueAdapter extends DisposableBean
KeyValueAdapter unifies access and shields the underlying key/value specific implementation.
Author:
Christoph Strobl, Thomas Darimont, Mark Paluch
  • Method Details

    • put

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

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

      @Nullable Object get(Object id, String keyspace)
      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.
    • get

      @Nullable <T> T get(Object id, String keyspace, Class<T> type)
      Get the object with given id from keyspace.
      Parameters:
      id - must not be null.
      keyspace - must not be null.
      type - must not be null.
      Returns:
      null in case no matching item exists.
      Since:
      1.1
    • delete

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

      @Nullable <T> T delete(Object id, String keyspace, Class<T> type)
      Delete and return the object with given type and id.
      Parameters:
      id - must not be null.
      keyspace - must not be null.
      type - must not be null.
      Returns:
      null if object could not be found
      Since:
      1.1
    • getAllOf

      Iterable<?> getAllOf(String keyspace)
      Get all elements for given keyspace.
      Parameters:
      keyspace - must not be null.
      Returns:
      empty Collection if nothing found.
    • getAllOf

      default <T> Iterable<T> getAllOf(String keyspace, Class<T> type)
      Get all elements for given keyspace.
      Parameters:
      keyspace - must not be null.
      type - must not be null.
      Returns:
      empty Collection if nothing found.
      Since:
      2.5
    • entries

      Returns a CloseableIterator that iterates over all entries.
      Parameters:
      keyspace - must not be null.
      Returns:
    • entries

      default <T> CloseableIterator<Map.Entry<Object,T>> entries(String keyspace, Class<T> type)
      Returns a CloseableIterator that iterates over all entries.
      Parameters:
      keyspace - must not be null.
      type - must not be null.
      Returns:
      Since:
      2.5
    • deleteAllOf

      void deleteAllOf(String keyspace)
      Remove all objects of given type.
      Parameters:
      keyspace - must not be null.
    • clear

      void clear()
      Removes all objects.
    • find

      default Iterable<?> find(KeyValueQuery<?> query, String keyspace)
      Find all matching objects within keyspace.
      Parameters:
      query - must not be null.
      keyspace - must not be null.
      Returns:
      empty Collection if no match found.
    • find

      <T> Iterable<T> find(KeyValueQuery<?> query, String keyspace, Class<T> type)
      Parameters:
      query - must not be null.
      keyspace - must not be null.
      type - must not be null.
      Returns:
      empty Collection if no match found.
      Since:
      1.1
    • count

      long count(String keyspace)
      Count number of objects within keyspace.
      Parameters:
      keyspace - must not be null.
      Returns:
    • count

      long count(KeyValueQuery<?> query, String keyspace)
      Count all matching objects within keyspace.
      Parameters:
      query - must not be null.
      keyspace - must not be null.
      Returns:
    • exists

      default boolean exists(KeyValueQuery<?> query, String keyspace)
      Determine whether result of given KeyValueQuery within keyspace contains at least one element.
      Parameters:
      query - must not be null.
      keyspace - must not be null.
      Returns:
      Since:
      2.7