Package org.cactoos

Class Fallback.From<T>

  • Type Parameters:
    T - Type of result
    All Implemented Interfaces:
    Fallback<T>, Func<Throwable,​T>
    Enclosing interface:
    Fallback<X>

    public static final class Fallback.From<T>
    extends Object
    implements Fallback<T>
    Fallback from exception.

    There is no thread-safety guarantee.

    Since:
    1.0
    • Constructor Detail

      • From

        public From​(Class<? extends Throwable> exp,
                    Func<Throwable,​T> func)
        Ctor.
        Parameters:
        exp - Supported exception type
        func - Function that converts the given exception into required one
      • From

        public From​(Iterable<Class<? extends Throwable>> exps,
                    Func<Throwable,​T> func)
        Ctor.
        Parameters:
        exps - Supported exceptions types
        func - Function that converts the given exception into required one
    • Method Detail

      • support

        public int support​(Throwable exception)
        Description copied from interface: Fallback
        Calculate level of support of the given exception type.
        Specified by:
        support in interface Fallback<T>
        Parameters:
        exception - Exception
        Returns:
        Level of support: greater or equals to 0 if the target is supported and Integer.MIN_VALUE otherwise