Class MetadataPatternMatcher


  • @InternalApi
    public abstract class MetadataPatternMatcher
    extends java.lang.Object
    Emulates behavior of a database metadata pattern.

    This behaves similar to (but not 100% identical to) a SQL LIKE pattern with ESCAPE '\' clause.

    This implementation is not thread-safe.

    Since:
    4.0
    Author:
    Mark Rotteveel
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static MetadataPatternMatcher fromPattern​(MetadataPattern metadataPattern)
      Derives a metadata pattern matcher from a metadata pattern instance.
      abstract boolean matches​(java.lang.String value)
      Checks if value matches the pattern of this matcher.
      static java.lang.String patternToRegex​(java.lang.String metadataPattern)
      Creates a regular expression pattern equivalent to the provided database metadata pattern.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • fromPattern

        public static MetadataPatternMatcher fromPattern​(MetadataPattern metadataPattern)
        Derives a metadata pattern matcher from a metadata pattern instance.
        Parameters:
        metadataPattern - Metadata pattern instance
        Returns:
        Matcher for metadataPattern
      • matches

        public abstract boolean matches​(java.lang.String value)
        Checks if value matches the pattern of this matcher.

        This method is not thread-safe.

        Parameters:
        value - Value to check
        Returns:
        true if value matches this pattern, false otherwise
      • patternToRegex

        public static java.lang.String patternToRegex​(java.lang.String metadataPattern)
        Creates a regular expression pattern equivalent to the provided database metadata pattern.
        Parameters:
        metadataPattern - database metadata pattern
        Returns:
        Pattern for the provided like string.