Package com.google.mu.collect
Class MoreCollections
java.lang.Object
com.google.mu.collect.MoreCollections
Utilities pertaining to
Collection
.- Since:
- 8.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
R> Optional <R> findFirstElements
(Collection<T> collection, MapFrom3<? super T, ? extends R> found) Ifcollection
has at least 3 elements, passes the first 3 elements tofound
function 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) Ifcollection
has at least 4 elements, passes the first 4 elements tofound
function 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) Ifcollection
has at least 5 elements, passes the first 5 elements tofound
function 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) Ifcollection
has at least 6 elements, passes the first 6 elements tofound
function 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) Ifcollection
has at least 7 elements, passes the first 6 elements tofound
function 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) Ifcollection
has at least 8 elements, passes the first 6 elements tofound
function 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) Ifcollection
has at least two elements, passes the first two elements tofound
function 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) Ifcollection
has exactly 3 elements, passes the 3 elements tofound
function 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) Ifcollection
has exactly 4 elements, passes the 4 elements tofound
function 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) Ifcollection
has exactly 5 elements, passes the 5 elements tofound
function 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) Ifcollection
has exactly 6 elements, passes the 6 elements tofound
function 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) Ifcollection
has exactly 7 elements, passes the 6 elements tofound
function 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) Ifcollection
has exactly 8 elements, passes the 6 elements tofound
function 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) Ifcollection
has exactly two elements, passes the two elements tofound
function 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) Ifcollection
has at least two elements, passes the first two elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom3<? super T, ? extends R> found) Ifcollection
has at least 3 elements, passes the first 3 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom4<? super T, ? extends R> found) Ifcollection
has at least 4 elements, passes the first 4 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom5<? super T, ? extends R> found) Ifcollection
has at least 5 elements, passes the first 5 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom6<? super T, ? extends R> found) Ifcollection
has at least 6 elements, passes the first 6 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom7<? super T, ? extends R> found) Ifcollection
has at least 7 elements, passes the first 6 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.- Since:
- 7.2
-
findFirstElements
public static <T,R> Optional<R> findFirstElements(Collection<T> collection, MapFrom8<? super T, ? extends R> found) Ifcollection
has at least 8 elements, passes the first 6 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
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) Ifcollection
has exactly two elements, passes the two elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom3<? super T, ? extends R> found) Ifcollection
has exactly 3 elements, passes the 3 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom4<? super T, ? extends R> found) Ifcollection
has exactly 4 elements, passes the 4 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom5<? super T, ? extends R> found) Ifcollection
has exactly 5 elements, passes the 5 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom6<? super T, ? extends R> found) Ifcollection
has exactly 6 elements, passes the 6 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom7<? super T, ? extends R> found) Ifcollection
has exactly 7 elements, passes the 6 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.- Since:
- 7.2
-
findOnlyElements
public static <T,R> Optional<R> findOnlyElements(Collection<T> collection, MapFrom8<? super T, ? extends R> found) Ifcollection
has exactly 8 elements, passes the 6 elements tofound
function and returns the non-null result wrapped in anOptional
, or else returnsOptional.empty()
.- Throws:
NullPointerException
- ifcollection
orfound
function is null, or iffound
function returns null.- Since:
- 7.2
-