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 ifleftandrightboth contain the same number of elements, and each pair of corresponding elements matches according to thematcherpredicate.
-
Method Details
-
pairwise
public static <A,B> boolean pairwise(Iterable<A> left, Iterable<B> right, BiPredicate<? super A, ? super B> matcher) Returns true ifleftandrightboth contain the same number of elements, and each pair of corresponding elements matches according to thematcherpredicate. If both iterables are empty, returns true.Note that this method performs a similar function for matching as
com.google.common.collect.Ordering.lexicographicaldoes for orderings.It can also be used to compare two
Optionalobjects, by first converting theOptionalinto aSetusingOptionals.asSet(java.util.Optional<? extends T>). For example:pairwise(asSet(resultProto1), asSet(resultProto2), differencer::compare)
-