Package com.google.mu.collect
Class MoreIterables
java.lang.Object
com.google.mu.collect.MoreIterables
Some additional utilities pertaining to
Iterable
.- Since:
- 8.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <A,
B> boolean pairwise
(Iterable<A> left, Iterable<B> right, BiPredicate<? super A, ? super B> matcher) Returns true ifleft
andright
both contain the same number of elements, and each pair of corresponding elements matches according to thematcher
predicate.
-
Method Details
-
pairwise
public static <A,B> boolean pairwise(Iterable<A> left, Iterable<B> right, BiPredicate<? super A, ? super B> matcher) Returns true ifleft
andright
both contain the same number of elements, and each pair of corresponding elements matches according to thematcher
predicate. If both iterables are empty, returns true.Note that this method performs a similar function for matching as
com.google.common.collect.Ordering.lexicographical
does for orderings.It can also be used to compare two
Optional
objects, by first converting theOptional
into aSet
usingOptionals.asSet(java.util.Optional<? extends T>)
. For example:pairwise(asSet(resultProto1), asSet(resultProto2), differencer::compare)
-