Package no.digipost
Class DiggPredicates
- java.lang.Object
-
- no.digipost.DiggPredicates
-
public final class DiggPredicates extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Predicate<T>nth(long n, Predicate<T> predicate)Create a new predicate which only yields true on the nthtrue-yielding invocation of a given predicate.
-
-
-
Method Detail
-
nth
public static <T> Predicate<T> nth(long n, Predicate<T> predicate)
Create a new predicate which only yields true on the nthtrue-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 nthtrue-yielding invocation,1indicates first,2second, and so forth.0or less will throw anIllegalArgumentException.predicate- the predicate.- Returns:
- the new predicate.
-
-