Class MoreCollections
java.lang.Object
com.google.mu.collect.MoreCollections
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,R> Optional <R> findFirstElements(Collection<T> collection, MapFrom3<? super T, ? extends R> found) Ifcollectionhas at least 3 elements, passes the first 3 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findFirstElements(Collection<T> collection, MapFrom4<? super T, ? extends R> found) Ifcollectionhas at least 4 elements, passes the first 4 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findFirstElements(Collection<T> collection, MapFrom5<? super T, ? extends R> found) Ifcollectionhas at least 5 elements, passes the first 5 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findFirstElements(Collection<T> collection, MapFrom6<? super T, ? extends R> found) Ifcollectionhas at least 6 elements, passes the first 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findFirstElements(Collection<T> collection, MapFrom7<? super T, ? extends R> found) Ifcollectionhas at least 7 elements, passes the first 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findFirstElements(Collection<T> collection, MapFrom8<? super T, ? extends R> found) Ifcollectionhas at least 8 elements, passes the first 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findFirstElements(Collection<T> collection, BiFunction<? super T, ? super T, ? extends R> found) Ifcollectionhas at least two elements, passes the first two elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findOnlyElements(Collection<T> collection, MapFrom3<? super T, ? extends R> found) Ifcollectionhas exactly 3 elements, passes the 3 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findOnlyElements(Collection<T> collection, MapFrom4<? super T, ? extends R> found) Ifcollectionhas exactly 4 elements, passes the 4 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findOnlyElements(Collection<T> collection, MapFrom5<? super T, ? extends R> found) Ifcollectionhas exactly 5 elements, passes the 5 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findOnlyElements(Collection<T> collection, MapFrom6<? super T, ? extends R> found) Ifcollectionhas exactly 6 elements, passes the 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findOnlyElements(Collection<T> collection, MapFrom7<? super T, ? extends R> found) Ifcollectionhas exactly 7 elements, passes the 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findOnlyElements(Collection<T> collection, MapFrom8<? super T, ? extends R> found) Ifcollectionhas exactly 8 elements, passes the 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().static <T,R> Optional <R> findOnlyElements(Collection<T> collection, BiFunction<? super T, ? super T, ? extends R> found) Ifcollectionhas exactly two elements, passes the two elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().
-
Method Details
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, BiFunction<? super T, ? super T, ? extends R> found) Ifcollectionhas at least two elements, passes the first two elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom3<? super T, ? extends R> found) Ifcollectionhas at least 3 elements, passes the first 3 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom4<? super T, ? extends R> found) Ifcollectionhas at least 4 elements, passes the first 4 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom5<? super T, ? extends R> found) Ifcollectionhas at least 5 elements, passes the first 5 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom6<? super T, ? extends R> found) Ifcollectionhas at least 6 elements, passes the first 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom7<? super T, ? extends R> found) Ifcollectionhas at least 7 elements, passes the first 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.- Since:
- 7.2
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom8<? super T, ? extends R> found) Ifcollectionhas at least 8 elements, passes the first 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.- Since:
- 7.2
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, BiFunction<? super T, ? super T, ? extends R> found) Ifcollectionhas exactly two elements, passes the two elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom3<? super T, ? extends R> found) Ifcollectionhas exactly 3 elements, passes the 3 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom4<? super T, ? extends R> found) Ifcollectionhas exactly 4 elements, passes the 4 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom5<? super T, ? extends R> found) Ifcollectionhas exactly 5 elements, passes the 5 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom6<? super T, ? extends R> found) Ifcollectionhas exactly 6 elements, passes the 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom7<? super T, ? extends R> found) Ifcollectionhas exactly 7 elements, passes the 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.- Since:
- 7.2
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom8<? super T, ? extends R> found) Ifcollectionhas exactly 8 elements, passes the 6 elements tofoundfunction and returns the non-null result wrapped in anOptional, or else returnsOptional.empty().- Throws:
NullPointerException- ifcollectionorfoundfunction is null, or iffoundfunction returns null.- Since:
- 7.2
-