Class Idler<T>

  • Type Parameters:
    T - the type value
    All Implemented Interfaces:
    Dealer<T>, Serializable, Supplier<T>

    public final class Idler<T>
    extends Object
    implements Supplier<T>, Dealer<T>, Serializable
    The Idlerr is intended to be memorized and idempotent. This can be very useful for operations with high latency whose result are used multitudinous. The operation is performed once and the result and served whenever needed and hence improving the performance.
    Since:
    1.0
    Author:
    , Bobai Kato
    See Also:
    Supplier, Dealer, Serialized Form
    • Method Detail

      • of

        @Contract("_, _ -> new")
        @NotNull
        public static <T> @NotNull Idler<T> of​(Dealer<T> dealer,
                                               Supplier<T> supplier)
      • of

        @Contract("_, _ -> new")
        @NotNull
        public static <T> @NotNull Idler<T> of​(Dealer<T> dealer)
      • of

        @Contract("_, _ -> new")
        @NotNull
        public static <T> @NotNull Idler<T> of​(Supplier<T> supplier,
                                               Dealer<T> dealer)
      • supply

        @Contract("_ -> new")
        @NotNull
        public static <T> @NotNull Supplier<T> supply​(Supplier<T> supplier)
        Supply take an instance of Supplier as parameter..
        Type Parameters:
        T - the type parameter
        Parameters:
        supplier - the supplier, an instance of Supplier
        Returns:
        the supplier, an instance of Supplier
      • deal

        @Contract("_ -> new")
        @NotNull
        public static <T> @NotNull Dealer<T> deal​(Dealer<T> dealer)
        Supply take an instance of Dealer as parameter..
        Type Parameters:
        T - the type parameter
        Parameters:
        dealer - the supplier, an instance of Dealer
        Returns:
        the supplier, an instance of Dealer
      • deal

        public T deal()
               throws Exception
        Gets a result for dealer operation.
        Specified by:
        deal in interface Dealer<T>
        Returns:
        a dealer result
        Throws:
        Exception - operation exception thrown
        See Also:
        Dealer.deal()
      • get

        public T get()
        Gets a result for supplier operation.
        Specified by:
        get in interface Supplier<T>
        Returns:
        a supplier result
        See Also:
        Supplier.get()
      • 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