Class LazyFunction<T,​R>

  • Type Parameters:
    T - the result type
    R - the return type
    All Implemented Interfaces:
    Serializable, Function<T,​R>

    public final class LazyFunction<T,​R>
    extends Object
    implements Function<T,​R>, Serializable
    The LazyFunction is intended to be memorized and idempotent for every parameter. This can be very useful for operations with high latency whose result are used multitudinous. .The result of every function operation are store and retrieves if the same parameter is passed instead of computing again. Every operation is performed once with unique parameters and the result and served whenever needed.
    Since:
    1.0
    Author:
    , Bobai Kato
    See Also:
    Function, Serialized Form
    • Method Detail

      • of

        @Contract("_ -> new")
        @NotNull
        public static <T,​R> @NotNull Function<T,​R> of​(Function<? super T,​? extends R> function)
        Take the function operation of Function type.
        Type Parameters:
        T - the type parameter
        R - the return type parameter
        Parameters:
        function - the function, of Function type
        Returns:
        the function, an instance of Function type.
      • apply

        public R apply​(T t)
        Applies this function to the given argument.
        Specified by:
        apply in interface Function<T,​R>
        Parameters:
        t - the function argument
        Returns:
        the function result
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        @Contract(value="null -> false",
                  pure=true)
        public boolean equals​(Object o)
        Overrides:
        equals in class Object