Interface DefaultFormatter

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

Default formatters. Unlike the mustache spec it will throw a NPE trying to format null objects.
Author:
agentgt
  • Method Details

    • format

      default <A extends Appendable, APPENDER extends Appender<A>> void format(APPENDER downstream, A a, String path, Class<?> c, @Nullable Object o) throws IOException
      Formats the object and then sends the results to the downstream appender. Will throw an NPE if parameter o is null.
      Specified by:
      format in interface Formatter
      Type Parameters:
      A - the appendable type
      APPENDER - the downstream appender 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:
      IOException - if the appender or appendable throws an exception
    • format

      default <A extends Appendable, APPENDER extends Appender<A>> void format(APPENDER downstream, A a, String path, String s) throws IOException
      Formats the object and then sends the results to the downstream appender. The default implementation passes natives through to the downstream appender. Will throw an NPE if parameter s is null.
      Specified by:
      format in interface Formatter
      Type Parameters:
      A - the appendable type
      APPENDER - the downstream appender 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
      Throws:
      IOException - if the appender or appendable throws an exception
    • provider

      static Formatter provider()
      Provides the default formatter for static lookup.
      Returns:
      the default formatter singleton