Interface SpecFormatter

All Superinterfaces:
Formatter, Function<@Nullable Object,String>

Formatter that follows the spec rules that if a variable is null it will be an empty string (ie NOOP).
  • Method Details

    • format

      default <A extends Output<E>, E extends Exception> void format(Appender downstream, A a, String path, Class<?> c, @Nullable Object o) throws E
      Formats the object and then sends the results to the downstream appender.
      Specified by:
      format in interface Formatter
      Type Parameters:
      A - the appendable type
      E - the appender exception type
      Parameters:
      downstream - the downstream appender to be used instead of the appendable directly
      a - the appendable to be passed to the appender
      path - the dotted mustache like path
      c - the object class but is not guaranteed to be accurate. If it is not known Object.class will be used.
      o - the object which maybe null
      Throws:
      E - if the appender or appendable throws an exception
    • format

      default <A extends Output<E>, E extends Exception> void format(Appender downstream, A a, String path, @Nullable String s) throws E
      Formats the object and then sends the results to the downstream appender. The default implementation calls Formatter.format(Appender, Output, String, Class, Object) and it is generally recommend you override for performance. Unlike the normal behavior of String.valueOf(Object) if a String is null then nothing will be rendered per the mustache spec. .
      Specified by:
      format in interface Formatter
      Type Parameters:
      A - the appendable type
      E - the appender exception type
      Parameters:
      downstream - the downstream appender to be used instead of the appendable directly
      a - the appendable to be passed to the appender
      path - the dotted mustache like path
      s - String value which maybe null.
      Throws:
      E - if the appender or appendable throws an exception
    • provider

      static Formatter provider()
      Provides the formatter for static lookup.
      Returns:
      the single instance of the spec formatter