public class Decorator<T> extends Object implements Mapper
Mustache.render(Object). The following snippet would render: "ooF".
MustacheEngine engine = MustacheEngineBuilder.newBuilder().build();
engine.compileMustache("{{reverse}}")
.render(decorate("Foo").compute("reverse", s -> new StringBuilder(s).reverse().toString()).build(engine));
Note that ReflectionResolver and MapResolver must be
registered in order to make it work.
Decorator.Builder| Modifier and Type | Class and Description |
|---|---|
static class |
Decorator.AbstractBuilder<T,B extends Decorator.AbstractBuilder<T,B>>
Logic shared accross various decorator-related builders.
|
static class |
Decorator.Builder<T> |
| Modifier and Type | Field and Description |
|---|---|
protected T |
delegate |
static String |
KEY_GET_DELEGATE |
| Modifier and Type | Method and Description |
|---|---|
static <T> Decorator.Builder<T> |
decorate(T delegate)
Returns a decorator builder for the specified delegate.
|
static <T> Decorator<T> |
decorate(T delegate,
Map<String,Function<T,Object>> mappings,
String delegateKey,
Configuration configuration)
Returns a decorator instance for the specified delegate and mappings.
|
Object |
get(String key) |
String |
toString() |
static <T> T |
unwrap(T instance)
This method is recursive.
|
public static final String KEY_GET_DELEGATE
protected final T delegate
public static <T> Decorator.Builder<T> decorate(T delegate)
delegate - Decorator.Builder.build(MustacheEngine)public static <T> Decorator<T> decorate(T delegate, Map<String,Function<T,Object>> mappings, String delegateKey, Configuration configuration)
delegate - mappings - delegateKey - May be nullconfiguration - public static <T> T unwrap(T instance)
Copyright © 2020. All rights reserved.