Class ConcurrentHashMapCrudOperations<K,​V extends AbstractEntity & UpdatableEntity,​M>

    • Method Detail

      • create

        public V create​(V value)
        Description copied from interface: CrudOperations
        Creates an object in the storage.
        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.
        Specified by:
        create in interface CrudOperations<K,​V extends AbstractEntity & UpdatableEntity>
        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
        See Also:
        AbstractEntity.getId()
      • read

        public V read​(String key)
        Description copied from interface: CrudOperations
        Returns object with the given key from the storage or null if object does not exist.
        If V implements ExpirableEntity this method should not return entities that are expired. See ExpirableEntity JavaDoc for more details. TODO: Consider returning Optional<V> instead.
        Specified by:
        read in interface CrudOperations<K,​V extends AbstractEntity & UpdatableEntity>
        Parameters:
        key - Key of the object. Must not be null.
        Returns:
        See description
      • update

        public V update​(V value)
        Description copied from interface: CrudOperations
        Updates the object with the key of the value's ID in the storage if it already exists.
        Specified by:
        update in interface CrudOperations<K,​V extends AbstractEntity & UpdatableEntity>
        Parameters:
        value - Updated value
        Returns:
        the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)
        See Also:
        AbstractEntity.getId()
      • delete

        public boolean delete​(String key)
        Description copied from interface: CrudOperations
        Deletes object with the given key from the storage, if exists, no-op otherwise.
        Specified by:
        delete in interface CrudOperations<K,​V extends AbstractEntity & UpdatableEntity>
        Returns:
        Returns true if the object has been deleted or result cannot be determined, false otherwise.
      • delete

        public long delete​(QueryParameters<M> queryParameters)
        Description copied from interface: CrudOperations
        Deletes objects that match the given criteria.
        Specified by:
        delete in interface CrudOperations<K,​V extends AbstractEntity & UpdatableEntity>
        Parameters:
        queryParameters - parameters for the query like firstResult, maxResult, requested ordering, etc.
        Returns:
        Number of removed objects (might return -1 if not supported)
      • read

        public Stream<V> read​(QueryParameters<M> queryParameters)
        Description copied from interface: CrudOperations
        Returns stream of objects satisfying given criteria from the storage. The criteria are specified in the given criteria builder based on model properties.
        If V implements ExpirableEntity this method should not return entities that are expired. See ExpirableEntity JavaDoc for more details.
        Specified by:
        read in interface CrudOperations<K,​V extends AbstractEntity & UpdatableEntity>
        Parameters:
        queryParameters - parameters for the query like firstResult, maxResult, requested ordering, etc.
        Returns:
        Stream of objects. Never returns null.
      • getCount

        public long getCount​(QueryParameters<M> queryParameters)
        Description copied from interface: CrudOperations
        Returns the number of objects satisfying given criteria from the storage. The criteria are specified in the given criteria builder based on model properties.
        Specified by:
        getCount in interface CrudOperations<K,​V extends AbstractEntity & UpdatableEntity>
        Parameters:
        queryParameters - parameters for the query like firstResult, maxResult, requested ordering, etc.
        Returns:
        Number of objects. Never returns null.