@JStacheFormatter
@JStacheFormatterTypes(types={java.net.URI.class,java.net.URL.class})
public interface SpecFormatter
extends Formatter
Formatter that follows the spec rules that if a variable is
null
it will
be an empty string (ie NOOP).-
Method Summary
Modifier and TypeMethodDescriptiondefault <A extends Appendable,
APPENDER extends Appender<A>>
voidFormats the object and then sends the results to the downstream appender.default <A extends Appendable,
APPENDER extends Appender<A>>
voidFormats the object and then sends the results to the downstream appender.static Formatter
provider()
Provides the formatter for static lookup.
-
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.- Specified by:
format
in interfaceFormatter
- Type Parameters:
A
- the appendable typeAPPENDER
- the downstream appender type- Parameters:
downstream
- the downstream appender to be used instead of the appendable directlya
- the appendable to be passed to the appenderpath
- the dotted mustache like pathc
- 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. Unlike the normal behavior ofString.valueOf(Object)
if a String is null then nothing will be rendered per the mustache spec. .- Specified by:
format
in interfaceFormatter
- Type Parameters:
A
- the appendable typeAPPENDER
- the downstream appender type- Parameters:
downstream
- the downstream appender to be used instead of the appendable directlya
- the appendable to be passed to the appenderpath
- the dotted mustache like paths
- String- Throws:
IOException
- if the appender or appendable throws an exception
-
provider
Provides the formatter for static lookup.- Returns:
- the single instance of the spec formatter
-