Interface IComputable<K,​V>

  • All Known Implementing Classes:
    AbstractComputable, Memoizer, SimpleCache

    public interface IComputable<K,​V>
    Interface to compute objects of type V identified by a key of type K
    Author:
    dirmeier
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      V compute​(K key)
      Compute an object of type V identified by the key of type K
      java.lang.Class<? super V> getValueClass()
      Getting the Class of the value this computable produces.
      static <K,​V>
      IComputable<K,​V>
      of​(java.lang.Class<? super V> valueClass, java.util.function.Function<K,​V> function)
      Creates a new IComputable for the given value class using the given Function to compute the values from keys.
    • Method Detail

      • compute

        V compute​(K key)
           throws java.lang.InterruptedException
        Compute an object of type V identified by the key of type K
        Parameters:
        key - the key to identify the object
        Returns:
        the computed Object of type V
        Throws:
        java.lang.InterruptedException - When computation was interrupted
      • getValueClass

        java.lang.Class<? super V> getValueClass()
        Getting the Class of the value this computable produces.
      • of

        static <K,​V> IComputable<K,​V> of​(java.lang.Class<? super V> valueClass,
                                                     java.util.function.Function<K,​V> function)
        Creates a new IComputable for the given value class using the given Function to compute the values from keys.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        valueClass - the class of the values
        function - the function to compute a value from a key
        Returns:
        a new IComputable