Class Optionals

java.lang.Object
com.yahoo.collections.Optionals

public class Optionals extends Object
Author:
jonmv
  • Method Details

    • firstNonEmpty

      @SafeVarargs public static <T> Optional<T> firstNonEmpty(Optional<T>... optionals)
      Returns the first non-empty optional, or empty if all are empty.
    • min

      @SafeVarargs public static <T extends Comparable<T>> Optional<T> min(Optional<T>... optionals)
      Returns the non-empty optional with the lowest value, or empty if all are empty.
    • max

      @SafeVarargs public static <T extends Comparable<T>> Optional<T> max(Optional<T>... optionals)
      Returns the non-empty optional with the highest value, or empty if all are empty.
    • equalIfBothPresent

      public static <T> boolean equalIfBothPresent(Optional<T> first, Optional<T> second)
      Returns whether either optional is empty, or both are present and equal.
    • emptyOrEqual

      public static <T> boolean emptyOrEqual(Optional<T> optional, T value)
      Returns whether the optional is empty, or present and equal to the given value.