### Question:
DecoratorConverter extends AbstractConfigurationAware implements ContextConverter { public static <T> Builder<T> decorate(Class<T> delegateType) { return decorate(o -> (delegateType.isAssignableFrom(Decorator.unwrap(o).getClass()))); } private  DecoratorConverter(Predicate<Object> test, String delegateKey, Map<String, Function<T, Object>> mappings); static Builder<T> decorate(Class<T> delegateType); static Builder<T> decorate(Predicate<Object> test); @SuppressWarnings("unchecked") @Override Object convert(Object from);  }### Answer:
@SuppressWarnings("unchecked") @Test public void testInterpolation() { MustacheEngine engine = MustacheEngineBuilder.newBuilder() .addContextConverter(decorate(String.class) .compute("reverse", string -> new StringBuilder(string).reverse().toString()).build()) .addContextConverter(decorate(Hammer.class).put("translate", "kladivo") .compute("name", hammer -> hammer.getName().toUpperCase()).build()) .addContextConverter(decorate(List.class).compute("reversed", list -> { List<?> reversed = new ArrayList<>(list); Collections.reverse(reversed); return reversed; }).build()).build(); assertEquals("ooF", engine.compileMustache("{{reverse}}").render("Foo")); assertEquals("kladivo EDGAR 10", engine.compileMustache("{{translate}} {{name}} {{age}}").render(new Hammer())); assertEquals("bravo:charlie:alpha:", engine.compileMustache("{{#each this.reversed}}{{.}}:{{/each}}") .render(ImmutableList.of("alpha", "charlie", "bravo"))); assertEquals("EDGAR 1000", engine.compileMustache("{{name}} {{age}}") .render(decorate(new Hammer()).put("age", 1000).build(engine))); }
@Test public void testGetDelegate() { MustacheEngine engine = MustacheEngineBuilder.newBuilder() .addContextConverter(decorate(Hammer.class).compute("name", h -> h.getName().toUpperCase()).build()) .build(); Hammer hammer = new Hammer(); assertEquals("EDGAR vs Edgar", engine.compileMustache("{{name}} vs {{delegate.name}}").render(hammer)); }