Package no.digipost

Class DiggPredicates


  • public final class DiggPredicates
    extends Object
    • Method Detail

      • nth

        public static <T> Predicate<T> nth​(long n,
                                           Predicate<T> predicate)
        Create a new predicate which only yields true on the nth true-yielding invocation of a given predicate.

        As this is a stateful predicate, it should usually not be kept as a reference, but used inline when processing a number of elements, with streams.

        Parameters:
        n - the nth true-yielding invocation, 1 indicates first, 2 second, and so forth. 0 or less will throw an IllegalArgumentException.
        predicate - the predicate.
        Returns:
        the new predicate.