Вот пример желаемого АПИ
class TemplateEngineTest {
private final static String TEMPLATE = "<test>${testName}</test>";
private Object templateEngine;
public void testEngine() {
TestDtoObject dto = new TestDtoObject();
String renderedTemplate = templateEngine.render(TEMPLATE, dto);
assert renderedTemplate.equals("<test>myTestName</test>");
TestDtoObject resultDtr = templateEngine.unrender(TEMPLATE, renderedTemplate, TestDtoObject.class);
assert dto.equals(resultDtr);
}
static class TestDtoObject {
String testName = "myTestName";
}
}