Class 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 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 a AssertionError 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.
      • result

        public Optional<V> result()
        Gets the result returned by the function associated with the first predicates that is true.
        Returns:
        an Optional value. Empty means that no predicates were true.