Interface FallbackStrategy<T>

Type Parameters:
T - Result type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface FallbackStrategy<T>
Functional contract for providing fallback values when an operation ultimately fails.
  • Method Summary

    Modifier and Type
    Method
    Description
    fallback(Exception exception)
    Produces a fallback value for the given exception.
    default boolean
    supports(Exception exception)
    Indicates whether this fallback can handle the provided exception.
  • Method Details

    • fallback

      T fallback(Exception exception)
      Produces a fallback value for the given exception.
      Parameters:
      exception - The exception that triggered the fallback
      Returns:
      Fallback value
    • supports

      default boolean supports(Exception exception)
      Indicates whether this fallback can handle the provided exception. Default implementation accepts all exceptions.
      Parameters:
      exception - Failure cause
      Returns:
      true if fallback should run