Class Retry<X,​Y>

  • Type Parameters:
    X - Type of input
    Y - Type of output
    All Implemented Interfaces:
    Func<X,​Y>

    public final class Retry<X,​Y>
    extends Object
    implements Func<X,​Y>
    Func that will try a few times before throwing an exception.

    There is no thread-safety guarantee.

    Since:
    0.8
    • Constructor Detail

      • Retry

        public Retry​(Func<X,​Y> fnc)
        Ctor.
        Parameters:
        fnc - Func original
      • Retry

        public Retry​(Func<X,​Y> fnc,
                     int attempts)
        Ctor.
        Parameters:
        fnc - Func original
        attempts - Maximum number of attempts
      • Retry

        public Retry​(Func<X,​Y> fnc,
                     int attempts,
                     Duration wait)
        Ctor.
        Parameters:
        fnc - Func original
        attempts - Maximum number of attempts
        wait - The executions of the function
      • Retry

        public Retry​(Func<X,​Y> fnc,
                     Func<Integer,​Boolean> ext)
        Ctor.
        Parameters:
        fnc - Func original
        ext - Exit condition, returns TRUE if there is no more reason to try
      • Retry

        public Retry​(Func<X,​Y> fnc,
                     Func<Integer,​Boolean> ext,
                     Duration wait)
        Ctor.
        Parameters:
        fnc - Func original
        ext - Exit condition, returns TRUE if there is no more reason to try
        wait - The executions of the function
    • Method Detail

      • apply

        public Y apply​(X input)
                throws Exception
        Description copied from interface: Func
        Apply it.
        Specified by:
        apply in interface Func<X,​Y>
        Parameters:
        input - The argument
        Returns:
        The result
        Throws:
        Exception - If fails