Class OptionalUtils

java.lang.Object
software.amazon.awssdk.utils.OptionalUtils

public final class OptionalUtils extends Object
Functions that make working with optionals easier.
  • Method Details

    • firstPresent

      @SafeVarargs public static <T> Optional<T> firstPresent(Optional<T> firstValue, Supplier<Optional<T>>... fallbackValues)
      Attempt to find a present-valued optional in a list of optionals.
      Parameters:
      firstValue - The first value that should be checked.
      fallbackValues - The suppliers we should check in order for a present value.
      Returns:
      The first present value (or Optional.empty() if none are present)
    • firstPresent

      public static <T> Optional<T> firstPresent(Optional<T> firstValue, Supplier<T> fallbackValue)