Class NamePattern

java.lang.Object
org.tentackle.maven.plugin.mcp.render.NamePattern

public class NamePattern extends Object
Matches names by substring, glob, or regular expression.

Which of the three a caller wants is obvious from what it wrote, so it is derived rather than configured: a regex: prefix selects a regular expression, a * or ? selects a glob, anything else is a case-insensitive substring.

Author:
harald
  • Field Details

    • REGEX_PREFIX

      public static final String REGEX_PREFIX
      The prefix selecting a regular expression.
      See Also:
    • ANY

      public static final NamePattern ANY
      Matches everything.
  • Constructor Details

    • NamePattern

      public NamePattern(String text)
      Creates a pattern.
      Parameters:
      text - the pattern text, null or empty to match everything
      Throws:
      IllegalArgumentException - if a regular expression is malformed
  • Method Details

    • matches

      public boolean matches(String name)
      Returns whether a name matches.
      Parameters:
      name - the name; may be null
      Returns:
      true if it matches
    • isAny

      public boolean isAny()
      Returns whether this pattern matches everything.
      Returns:
      true if unrestricted
    • toString

      public String toString()
      Overrides:
      toString in class Object