Interface Storage<K,​V>

  • Type Parameters:
    K - DataType of key which is used to save value
    V - DataType of objects which should be stored
    All Known Implementing Classes:
    AbstractFileStorage, GenericFileStorage

    public interface Storage<K,​V>

    Storage Interface for storing objects

    Since:
    2.0
    Author:
    Christoph Praschl
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      K create​(V value)
      Method for storing an given object
      K create​(V value, K suggestedKey)
      Method for storing an given object
      boolean delete​(K key)
      Method for deleting a stored object
      boolean deleteAll()
      Method for deleting all stored objects Attention: If corresponding folder is used by multiple users/application this method does not take response for them! Only use it if the folder is only touched by this Storage
      Collection<V> read()
      Method for reading all objects managed by the storage
      V read​(K key)
      Method for reading an object identified by the given key
      boolean update​(K key, V value)
      Method for updating the stored object at a given key
    • Method Detail

      • create

        K create​(V value)
        Method for storing an given object
        Parameters:
        value - Object which should be stored
        Returns:
        The key of the stored object
      • create

        K create​(V value,
                 K suggestedKey)
        Method for storing an given object
        Parameters:
        value - Object which should be stored
        suggestedKey - Suggested Key for storing the object (does not have to be considered! check return value)
        Returns:
        The key of the stored object
      • read

        V read​(K key)
        Method for reading an object identified by the given key
        Parameters:
        key - Key to identify the object which should be read
        Returns:
        The Object identified by the key or NULL if no object is identified by the given key.
      • read

        Collection<V> read()
        Method for reading all objects managed by the storage
        Returns:
        Collection of all managed objects
      • update

        boolean update​(K key,
                       V value)
        Method for updating the stored object at a given key
        Parameters:
        key - Key to identify the object which should be updated
        value - Object which should be restored
        Returns:
        True if object was updated; else false
      • delete

        boolean delete​(K key)
        Method for deleting a stored object
        Parameters:
        key - Key to identify the object which should be deleted
        Returns:
        True if object was deleted; else false
      • deleteAll

        boolean deleteAll()
        Method for deleting all stored objects Attention: If corresponding folder is used by multiple users/application this method does not take response for them! Only use it if the folder is only touched by this Storage
        Returns:
        True if object was deleted; else false