Class OptionalUtils


  • public final class OptionalUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.List<T> filterEmptyOptionals​(java.util.Collection<java.util.Optional<T>> optionals)
      Takes a Collection of Optionals containing some elements of type T, this method filters out any empty Optional and returns a new list containing the values of the non-empty optionals.
      static <T> java.util.List<T> filterEmptyOptionals​(java.util.Optional<T>... optionals)
      Takes zero or more Optionals containing some elements of type T, this method filters out any empty Optional and returns a new list containing the values of the non-empty optionals.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • filterEmptyOptionals

        @Nonnull
        public static <T> java.util.List<T> filterEmptyOptionals​(@Nonnull
                                                                 java.util.Collection<java.util.Optional<T>> optionals)
        Takes a Collection of Optionals containing some elements of type T, this method filters out any empty Optional and returns a new list containing the values of the non-empty optionals.
        Type Parameters:
        T - The type of the elements in the Optionals in the supplied collection optionals.
        Parameters:
        optionals - the collection of optionals that should be filtered out of empty optionals.
        Returns:
        a new list containing the values of the non-empty optionals from the supplied optionals collection.
      • filterEmptyOptionals

        @Nonnull
        @SafeVarargs
        public static <T> java.util.List<T> filterEmptyOptionals​(@Nonnull
                                                                 java.util.Optional<T>... optionals)
        Takes zero or more Optionals containing some elements of type T, this method filters out any empty Optional and returns a new list containing the values of the non-empty optionals.
        Type Parameters:
        T - The type of the elements in the Optionals in the supplied collection optionals.
        Parameters:
        optionals - zero or more optionals that should be filtered out of empty optionals.
        Returns:
        a new list containing the values of the non-empty optionals from the supplied optionals.