Class AbstractManagedProvider<E extends Identifiable<K>,​K,​PE>

    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
    • Constructor Detail

      • AbstractManagedProvider

        public AbstractManagedProvider​(StorageService storageService)
    • Method Detail

      • get

        public E get​(K key)
        Description copied from interface: ManagedProvider
        Returns an element for the given key or null if no element for the given key exists.
        Specified by:
        get in interface ManagedProvider<E extends Identifiable<K>,​K>
        Parameters:
        key - key
        Returns:
        returns element or null, if no element for the given key exists
      • remove

        public E remove​(K key)
        Description copied from interface: ManagedProvider
        Removes an element and returns the removed element.
        Specified by:
        remove in interface ManagedProvider<E extends Identifiable<K>,​K>
        Parameters:
        key - key of the element that should be removed
        Returns:
        element that was removed, or null if no element with the given key exists
      • update

        public E update​(E element)
        Description copied from interface: ManagedProvider
        Updates an element.
        Specified by:
        update in interface ManagedProvider<E extends Identifiable<K>,​K>
        Parameters:
        element - element to be updated
        Returns:
        returns the old element or null if no element with the same key exists
      • getStorageName

        protected abstract String getStorageName()
        Returns the name of storage, that is used to persist the elements.
        Returns:
        name of the storage
      • keyToString

        protected abstract @NonNull String keyToString​(@NonNull K key)
        Transforms the key into a string representation.
        Parameters:
        key - key
        Returns:
        string representation of the key
      • toElement

        protected abstract E toElement​(@NonNull String key,
                                       @NonNull PE persistableElement)
        Converts the persistable element into the original element.
        Parameters:
        key - key
        persistableElement - persistable element
        Returns:
        original element
      • toPersistableElement

        protected abstract PE toPersistableElement​(E element)
        Converts the original element into an element that can be persisted.
        Parameters:
        element - original element
        Returns:
        persistable element