Enum Class DetailsMessageFormatters

java.lang.Object
java.lang.Enum<DetailsMessageFormatters>
io.github.venkateshamurthy.exceptional.exceptions.DetailsMessageFormatters
All Implemented Interfaces:
Serializable, Comparable<DetailsMessageFormatters>, java.lang.constant.Constable

public enum DetailsMessageFormatters extends Enum<DetailsMessageFormatters>
An enumeration of Message formatters that can be used to format the detail message.
  • Enum Constant Details

    • NONE

      public static final DetailsMessageFormatters NONE
      A no/none formatting enum to be used as a catch-all default if no other pattern works.
    • SLF4J

      public static final DetailsMessageFormatters SLF4J
      A SLF4J logger style empty braces pattern.
    • DOUBLEANGULAR

      public static final DetailsMessageFormatters DOUBLEANGULAR
      A double angular braces <<>> marker.
    • $BRACES

      public static final DetailsMessageFormatters $BRACES
      A apache commons style ${somekey} pattern.
    • NAMEDARGS

      public static final DetailsMessageFormatters NAMEDARGS
      A named {key} pattern which would be replaced by a mapped value from a key-value map.
    • JAVA

      public static final DetailsMessageFormatters JAVA
      A Standard Java style MessageFormat pattern - just the way printf works.
  • Method Details

    • values

      public static DetailsMessageFormatters[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DetailsMessageFormatters valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • format

      public abstract String format(String template, Object... values)
      Method to format a given template and values.
      Parameters:
      template - a marker-ed template where each marker style is specific to the instance's pattern
      values - could be var-arg style argument values that is allowed in all the formats. However it could just be a map (of key-value pairs) if NAMEDARGS is used.
      Returns:
      formatted string
    • detectFormatter

      public static DetailsMessageFormatters detectFormatter(String template)
      A detection of formatter given a template
      Parameters:
      template - to be introspected to know which formatter style works to replace values
      Returns:
      the matching DetailsMessageFormatters iff only one formatter matches.
      Throws:
      IllegalArgumentException - in case of no suitable formatter determined or multiple formatters matching.
    • detectAndFormat

      public static String detectAndFormat(String template, Object... values)
      A convenient static method to determine format and format
      Parameters:
      template - the string template
      values - the values to replace
      Returns:
      formated template with values (if required with NONE).