Interface KeyValueOperations

All Superinterfaces:
DisposableBean
All Known Implementing Classes:
KeyValueTemplate

public interface KeyValueOperations extends DisposableBean
Interface that specifies a basic set of key/value operations. Implemented by KeyValueTemplate.
Author:
Christoph Strobl, Mark Paluch
  • Method Details

    • insert

      <T> T insert(T objectToInsert)
      Add given object. Object needs to have id property to which a generated value will be assigned.
      Parameters:
      objectToInsert -
      Returns:
      the inserted object.
    • insert

      <T> T insert(Object id, T objectToInsert)
      Add object with given id.
      Parameters:
      id - must not be null.
      objectToInsert - must not be null.
      Returns:
      the inserted object.
    • findAll

      <T> Iterable<T> findAll(Class<T> type)
      Get all elements of given type. Respects KeySpace if present and therefore returns all elements that can be assigned to requested type.
      Parameters:
      type - must not be null.
      Returns:
      empty iterable if no elements found.
    • findAll

      <T> Iterable<T> findAll(Sort sort, Class<T> type)
      Get all elements ordered by sort. Respects KeySpace if present and therefore returns all elements that can be assigned to requested type.
      Parameters:
      sort - must not be null.
      type - must not be null.
      Returns:
    • findById

      <T> Optional<T> findById(Object id, Class<T> type)
      Get element of given type with given id. Respects KeySpace if present and therefore returns all elements that can be assigned to requested type.
      Parameters:
      id - must not be null.
      type - must not be null.
      Returns:
      Optional.empty() if not found.
    • execute

      @Nullable <T> T execute(KeyValueCallback<T> action)
      Execute operation against underlying store.
      Parameters:
      action - must not be null.
      Returns:
    • find

      <T> Iterable<T> find(KeyValueQuery<?> query, Class<T> type)
      Get all elements matching the given query.
      Respects KeySpace if present and therefore returns all elements that can be assigned to requested type..
      Parameters:
      query - must not be null.
      type - must not be null.
      Returns:
      empty iterable if no match found.
    • findInRange

      <T> Iterable<T> findInRange(long offset, int rows, Class<T> type)
      Get all elements in given range. Respects KeySpace if present and therefore returns all elements that can be assigned to requested type.
      Parameters:
      offset -
      rows -
      type - must not be null.
      Returns:
    • findInRange

      <T> Iterable<T> findInRange(long offset, int rows, Sort sort, Class<T> type)
      Get all elements in given range ordered by sort. Respects KeySpace if present and therefore returns all elements that can be assigned to requested type.
      Parameters:
      offset -
      rows -
      sort -
      type -
      Returns:
    • update

      <T> T update(T objectToUpdate)
      Parameters:
      objectToUpdate - must not be null.
      Returns:
      the updated object.
    • update

      <T> T update(Object id, T objectToUpdate)
      Parameters:
      id - must not be null.
      objectToUpdate - must not be null.
      Returns:
      the updated object.
    • delete

      void delete(Class<?> type)
      Remove all elements of type. Respects KeySpace if present and therefore removes all elements that can be assigned to requested type.
      Parameters:
      type - must not be null.
    • delete

      @Nullable <T> T delete(T objectToDelete)
      Parameters:
      objectToDelete - must not be null.
      Returns:
    • delete

      @Nullable <T> T delete(Object id, Class<T> type)
      Delete item of type with given id.
      Parameters:
      id - must not be null.
      type - must not be null.
      Returns:
      the deleted item or null if no match found.
    • count

      long count(Class<?> type)
      Total number of elements with given type available. Respects KeySpace if present and therefore counts all elements that can be assigned to requested type.
      Parameters:
      type - must not be null.
      Returns:
    • count

      long count(KeyValueQuery<?> query, Class<?> type)
      Total number of elements matching given query. Respects KeySpace if present and therefore counts all elements that can be assigned to requested type.
      Parameters:
      query -
      type -
      Returns:
    • exists

      boolean exists(KeyValueQuery<?> query, Class<?> type)
      Determine whether result of given KeyValueQuery contains at least one element.
      Parameters:
      query -
      type -
      Returns:
      Since:
      2.7
    • getMappingContext

      MappingContext<?,?> getMappingContext()
      Returns:
      mapping context in use.
    • getKeyValueAdapter

      KeyValueAdapter getKeyValueAdapter()
      Returns:
      KeyValueAdapter in use.
      Since:
      3.2.4