Class PatternFormat

  • All Implemented Interfaces:
    Format

    public class PatternFormat
    extends java.lang.Object
    implements Format
    Format using a regex pattern.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String errorMessageDescription  
      private java.lang.String messageKey  
      private java.lang.String name  
      private java.util.regex.Pattern pattern  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        PatternFormat​(java.lang.String name, java.lang.String regex, java.lang.String errorMessageDescription)
      Deprecated.
      private PatternFormat​(java.lang.String name, java.lang.String regex, java.lang.String errorMessageDescription, java.lang.String messageKey)  
    • Field Detail

      • name

        private final java.lang.String name
      • pattern

        private final java.util.regex.Pattern pattern
      • messageKey

        private final java.lang.String messageKey
      • errorMessageDescription

        private final java.lang.String errorMessageDescription
    • Constructor Detail

      • PatternFormat

        @Deprecated
        public PatternFormat​(java.lang.String name,
                             java.lang.String regex,
                             java.lang.String errorMessageDescription)
        Deprecated.
        Constructor.

        Use of(String, String, String) instead.

        Parameters:
        name - the name
        regex - the regex
        errorMessageDescription - the error message description
      • PatternFormat

        private PatternFormat​(java.lang.String name,
                              java.lang.String regex,
                              java.lang.String errorMessageDescription,
                              java.lang.String messageKey)
    • Method Detail

      • of

        public static PatternFormat of​(java.lang.String name,
                                       java.lang.String regex,
                                       java.lang.String messageKey)
        Creates a pattern format.
        Parameters:
        name - the name
        regex - the regex pattern
        messageKey - the message key
        Returns:
        the pattern format
      • matches

        public boolean matches​(ExecutionContext executionContext,
                               java.lang.String value)
        Description copied from interface: Format
        Determines if the value matches the format.

        This should be implemented for string node types.

        Specified by:
        matches in interface Format
        Parameters:
        executionContext - the execution context
        value - to match
        Returns:
        true if matches
      • getName

        public java.lang.String getName()
        Description copied from interface: Format
        Gets the format name.
        Specified by:
        getName in interface Format
        Returns:
        the format name as referred to in a json schema format node.
      • getMessageKey

        public java.lang.String getMessageKey()
        Description copied from interface: Format
        Gets the message key to use for the message.

        See jsv-messages.properties.

        The following are the arguments.
        {0} The instance location
        {1} The format name
        {2} The error message description
        {3} The input value

        Specified by:
        getMessageKey in interface Format
        Returns:
        the message key
      • getErrorMessageDescription

        public java.lang.String getErrorMessageDescription()
        Description copied from interface: Format
        Gets the error message description.

        Deprecated. Override getMessageKey() and set the localized message in the resource bundle or message source.

        Specified by:
        getErrorMessageDescription in interface Format
        Returns:
        the error message description.