Class GlobMatcher<T>


  • public class GlobMatcher<T>
    extends Object
    A type-generalized pattern matcher supporting "glob" expressions.

    A glob pattern is a sequence of values of type T. Among these values, two values are distinguished:

    • a symbol that is interpreted in a given pattern to mean match any single value in the input
    • a symbol that is interpreted in a given pattern to mean match any sequence of input (including an empty sequence)

    An input sequence of values of type T is matched against the pattern by interpreting each value of the input and the pattern in order, applying either equals, match-any, or match-any-sequence according to the pattern specification.

    When the base type is Character and the match any symbol is "?" and the match any sequence is "*", the GlobMatcher takes on the semantics of ordinary filename globbing for string (character array) inputs.

    Author:
    Carl Harris
    • Method Detail

      • with

        public static <T> GlobMatcher<T> with​(T anyInputToken,
                                              T anyInputSequenceToken,
                                              T[] pattern)
      • matches

        public boolean matches​(T[] input)
        Tests the given input as a match for this pattern.
        Parameters:
        input - the input to test
        Returns:
        true if input matches this pattern
      • matches

        public boolean matches​(List<T> input)
        Tests the given input as a match for this pattern.
        Parameters:
        input - the input to test
        Returns:
        true if input matches this pattern