Class MoreCollections

java.lang.Object
com.google.mu.collect.MoreCollections

public final class MoreCollections extends Object
Utilities pertaining to Collection.
Since:
8.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T, R> Optional<R>
    findFirstElements(Collection<T> collection, MapFrom3<? super T,? extends R> found)
    If collection has at least 3 elements, passes the first 3 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findFirstElements(Collection<T> collection, MapFrom4<? super T,? extends R> found)
    If collection has at least 4 elements, passes the first 4 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findFirstElements(Collection<T> collection, MapFrom5<? super T,? extends R> found)
    If collection has at least 5 elements, passes the first 5 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findFirstElements(Collection<T> collection, MapFrom6<? super T,? extends R> found)
    If collection has at least 6 elements, passes the first 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findFirstElements(Collection<T> collection, MapFrom7<? super T,? extends R> found)
    If collection has at least 7 elements, passes the first 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findFirstElements(Collection<T> collection, MapFrom8<? super T,? extends R> found)
    If collection has at least 8 elements, passes the first 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findFirstElements(Collection<T> collection, BiFunction<? super T,? super T,? extends R> found)
    If collection has at least two elements, passes the first two elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findOnlyElements(Collection<T> collection, MapFrom3<? super T,? extends R> found)
    If collection has exactly 3 elements, passes the 3 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findOnlyElements(Collection<T> collection, MapFrom4<? super T,? extends R> found)
    If collection has exactly 4 elements, passes the 4 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findOnlyElements(Collection<T> collection, MapFrom5<? super T,? extends R> found)
    If collection has exactly 5 elements, passes the 5 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findOnlyElements(Collection<T> collection, MapFrom6<? super T,? extends R> found)
    If collection has exactly 6 elements, passes the 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findOnlyElements(Collection<T> collection, MapFrom7<? super T,? extends R> found)
    If collection has exactly 7 elements, passes the 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findOnlyElements(Collection<T> collection, MapFrom8<? super T,? extends R> found)
    If collection has exactly 8 elements, passes the 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
    static <T, R> Optional<R>
    findOnlyElements(Collection<T> collection, BiFunction<? super T,? super T,? extends R> found)
    If collection has exactly two elements, passes the two elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().

    Methods inherited from class java.lang.Object

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

    • findFirstElements

      public static <T, R> Optional<R> findFirstElements(Collection<T> collection, BiFunction<? super T,? super T,? extends R> found)
      If collection has at least two elements, passes the first two elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findFirstElements

      public static <T, R> Optional<R> findFirstElements(Collection<T> collection, MapFrom3<? super T,? extends R> found)
      If collection has at least 3 elements, passes the first 3 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findFirstElements

      public static <T, R> Optional<R> findFirstElements(Collection<T> collection, MapFrom4<? super T,? extends R> found)
      If collection has at least 4 elements, passes the first 4 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findFirstElements

      public static <T, R> Optional<R> findFirstElements(Collection<T> collection, MapFrom5<? super T,? extends R> found)
      If collection has at least 5 elements, passes the first 5 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findFirstElements

      public static <T, R> Optional<R> findFirstElements(Collection<T> collection, MapFrom6<? super T,? extends R> found)
      If collection has at least 6 elements, passes the first 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findFirstElements

      public static <T, R> Optional<R> findFirstElements(Collection<T> collection, MapFrom7<? super T,? extends R> found)
      If collection has at least 7 elements, passes the first 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
      Since:
      7.2
    • findFirstElements

      public static <T, R> Optional<R> findFirstElements(Collection<T> collection, MapFrom8<? super T,? extends R> found)
      If collection has at least 8 elements, passes the first 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
      Since:
      7.2
    • findOnlyElements

      public static <T, R> Optional<R> findOnlyElements(Collection<T> collection, BiFunction<? super T,? super T,? extends R> found)
      If collection has exactly two elements, passes the two elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findOnlyElements

      public static <T, R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom3<? super T,? extends R> found)
      If collection has exactly 3 elements, passes the 3 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findOnlyElements

      public static <T, R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom4<? super T,? extends R> found)
      If collection has exactly 4 elements, passes the 4 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findOnlyElements

      public static <T, R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom5<? super T,? extends R> found)
      If collection has exactly 5 elements, passes the 5 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findOnlyElements

      public static <T, R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom6<? super T,? extends R> found)
      If collection has exactly 6 elements, passes the 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
    • findOnlyElements

      public static <T, R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom7<? super T,? extends R> found)
      If collection has exactly 7 elements, passes the 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
      Since:
      7.2
    • findOnlyElements

      public static <T, R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom8<? super T,? extends R> found)
      If collection has exactly 8 elements, passes the 6 elements to found function and returns the non-null result wrapped in an Optional, or else returns Optional.empty().
      Throws:
      NullPointerException - if collection or found function is null, or if found function returns null.
      Since:
      7.2