Class CountingPredicate<T>
java.lang.Object
org.kiwiproject.beta.util.function.CountingPredicate<T>
- All Implemented Interfaces:
Predicate<T>
A
Predicate that wraps a Predicate and tracks the number of
true and false results.
This should be used only on one stream, unless you want to continue to accumulate the number of true and false results over multiple streams.
Exceptions thrown by the wrapped Predicate are passed through.
-
Constructor Summary
ConstructorsConstructorDescriptionCountingPredicate(Predicate<T> predicate) Create a new instance that wrapspredicatein order to count the number of true and false results. -
Method Summary
Modifier and TypeMethodDescription@org.checkerframework.checker.index.qual.NonNegative longReturn the number of times this predicate has gotten afalseresult.boolean@org.checkerframework.checker.index.qual.NonNegative longReturn the number of times this predicate has gotten atrueresult.
-
Constructor Details
-
CountingPredicate
Create a new instance that wrapspredicatein order to count the number of true and false results.- Parameters:
predicate- the originalPredicateto wrap
-
-
Method Details
-
test
-
trueCount
public @org.checkerframework.checker.index.qual.NonNegative long trueCount()Return the number of times this predicate has gotten atrueresult.- Returns:
- the total number of true results
-
falseCount
public @org.checkerframework.checker.index.qual.NonNegative long falseCount()Return the number of times this predicate has gotten afalseresult.- Returns:
- the total number of false results
-