Class MoreIterables

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

public final class MoreIterables extends Object
Some additional utilities pertaining to Iterable.
Since:
8.0
  • Method Details

    • pairwise

      public static <A, B> boolean pairwise(Iterable<A> left, Iterable<B> right, BiPredicate<? super A,? super B> matcher)
      Returns true if left and right both contain the same number of elements, and each pair of corresponding elements matches according to the matcher 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 the Optional into a Set using Optionals.asSet(java.util.Optional<? extends T>). For example:

      
       pairwise(asSet(resultProto1), asSet(resultProto2), differencer::compare)