Interface ConcurrentHashMapCrudOperations<V extends AbstractEntity & UpdatableEntity,​M>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      V create​(V value)
      Creates an object in the store.
      boolean delete​(String key)
      Deletes object with the given key from the storage, if exists, no-op otherwise.
      long delete​(QueryParameters<M> queryParameters)
      Deletes objects that match the given criteria.
      long getCount​(QueryParameters<M> queryParameters)
      Returns the number of objects satisfying given criteria from the storage.
      V read​(String key)
      Returns object with the given key from the storage or null if object does not exist.
      Stream<V> read​(QueryParameters<M> queryParameters)
      Returns stream of objects satisfying given criteria from the storage.
      V update​(V value)
      Updates the object with the key of the value's ID in the storage if it already exists.
    • Method Detail

      • create

        V create​(V value)
        Creates an object in the store. ID of the value may be prescribed in id of the value. If the id is null or its format is not matching the store internal format for ID, then the value's ID will be generated and returned in the id of the return value.
        Parameters:
        value - Entity to create in the store
        Returns:
        Entity representing the value in the store. It may or may not be the same instance as value
        Throws:
        NullPointerException - if value is null
        See Also:
        AbstractEntity.getId()
      • read

        V read​(String key)
        Returns object with the given key from the storage or null if object does not exist.
        TODO: Consider returning Optional<V> instead.
        Parameters:
        key - Key of the object. Must not be null.
        Returns:
        See description
        Throws:
        NullPointerException - if the key is null
      • update

        V update​(V value)
        Updates the object with the key of the value's ID in the storage if it already exists.
        Parameters:
        value - Updated value
        Throws:
        NullPointerException - if the object or its id is null
        See Also:
        AbstractEntity.getId()
      • delete

        boolean delete​(String key)
        Deletes object with the given key from the storage, if exists, no-op otherwise.
        Parameters:
        key -
        Returns:
        Returns true if the object has been deleted or result cannot be determined, false otherwise.
      • delete

        long delete​(QueryParameters<M> queryParameters)
        Deletes objects that match the given criteria.
        Parameters:
        queryParameters - parameters for the query like firstResult, maxResult, requested ordering, etc.
        Returns:
        Number of removed objects (might return -1 if not supported)
      • read

        Stream<V> read​(QueryParameters<M> queryParameters)
        Returns stream of objects satisfying given criteria from the storage. The criteria are specified in the given criteria builder based on model properties.
        Parameters:
        queryParameters - parameters for the query like firstResult, maxResult, requested ordering, etc.
        Returns:
        Stream of objects. Never returns null.
      • getCount

        long getCount​(QueryParameters<M> queryParameters)
        Returns the number of objects satisfying given criteria from the storage. The criteria are specified in the given criteria builder based on model properties.
        Parameters:
        queryParameters - parameters for the query like firstResult, maxResult, requested ordering, etc.
        Returns:
        Number of objects. Never returns null.