Class Formatter


  • public final class Formatter
    extends java.lang.Object
    Tag resolvers producing tags that insert formatted values.

    These are effectively placeholders.

    Since:
    4.11.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static TagResolver booleanChoice​(@NotNull java.lang.String key, boolean value)
      Creates a choice tag.
      static @NotNull TagResolver choice​(@NotNull java.lang.String key, java.lang.Number number)
      Creates a replacement that inserts a choice formatted text.
      static @NotNull TagResolver date​(@NotNull java.lang.String key, @NotNull java.time.temporal.TemporalAccessor time)
      Creates a replacement that inserts a date or a time as a component.
      static @NotNull TagResolver number​(@NotNull java.lang.String key, @NotNull java.lang.Number number)
      Creates a replacement that inserts a number as a component.
      • Methods inherited from class java.lang.Object

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

      • number

        @NotNull
        public static @NotNull TagResolver number​(@TagPattern @NotNull
                                                  @NotNull java.lang.String key,
                                                  @NotNull
                                                  @NotNull java.lang.Number number)
        Creates a replacement that inserts a number as a component. The component will be formatted by the provided DecimalFormat.

        This tag accepts a locale, a format pattern, both or nothing as arguments. The locale has to be provided as first argument.

        Refer to Locale for usable locale tags. Refer to DecimalFormat for usable patterns.

        This replacement is auto-closing, so its style will not influence the style of following components.

        Parameters:
        key - the key
        number - the number
        Returns:
        the placeholder
        Since:
        4.11.0
      • date

        @NotNull
        public static @NotNull TagResolver date​(@TagPattern @NotNull
                                                @NotNull java.lang.String key,
                                                @NotNull
                                                @NotNull java.time.temporal.TemporalAccessor time)
        Creates a replacement that inserts a date or a time as a component. The component will be formatted by the provided Date Format.

        This tag expects a format as attribute. Refer to DateTimeFormatter for usable patterns.

        This replacement is auto-closing, so its style will not influence the style of following components.

        Parameters:
        key - the key
        time - the time
        Returns:
        the placeholder
        Since:
        4.11.0
      • choice

        @NotNull
        public static @NotNull TagResolver choice​(@TagPattern @NotNull
                                                  @NotNull java.lang.String key,
                                                  java.lang.Number number)
        Creates a replacement that inserts a choice formatted text. The component will be formatted by the provided ChoiceFormat.

        This tag expectes a format as attribute. Refer to ChoiceFormat for usable patterns.

        This replacement is auto-closing, so its style will not influence the style of following components.

        Parameters:
        key - the key
        number - the number
        Returns:
        the placeholder
        Since:
        4.11.0
      • booleanChoice

        public static TagResolver booleanChoice​(@TagPattern @NotNull
                                                @NotNull java.lang.String key,
                                                boolean value)
        Creates a choice tag. This will use the first argument when true, otherwise the second argument.

        This tag expects two formats as attributes.

        This replacement is auto-closing, so its style will not influence the style of following components.

        Parameters:
        key - the key
        value - the value
        Returns:
        the placeholder
        Since:
        4.13.0