Package org.silverpeas.core.util.filter
Class FilterMatcher<T,U,V>
- java.lang.Object
-
- org.silverpeas.core.util.filter.FilterMatcher<T,U,V>
-
- Direct Known Subclasses:
EmptyFilterMatcher
public class FilterMatcher<T,U,V> extends Object
A filter matcher. It applies each matching rules and kept the result of the first predicate that is true. Once a predicate is true, all other predicates aren't verified and then the associated operations aren't executed.- Author:
- mmoquillon
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FilterMatcher<T,U,V>
matchFirst(Predicate<T> predicate, Function<U,V> function)
Plays the specified predicate against the criterion and applies the specified function if and only if the predicate is true.Optional<V>
result()
Gets the result returned by the function associated with the first predicates that is true.
-
-
-
Method Detail
-
matchFirst
public FilterMatcher<T,U,V> matchFirst(Predicate<T> predicate, Function<U,V> function)
Plays the specified predicate against the criterion and applies the specified function if and only if the predicate is true. If the criterion is true, the result is stored and the other next predicates aren't played. The result of the function cannot be null otherwise aAssertionError
is thrown.- Parameters:
predicate
- the predicate to match.function
- the function associated with the predicate and that returns a non-null computation result.- Returns:
- itself.
-
-