@Test public void testAppliesTo() { HtmlEscaper html = new HtmlEscaper(); Origin htmlOrigin = new Origin() { @Override public Optional<Variant> getVariant() { return Optional.of(new Variant(Locale.getDefault(), Variant.TEXT_HTML, null)); } @Override public String getTemplateId() { return null; } @Override public String getTemplateGeneratedId() { return null; } @Override public int getLineCharacter() { return 0; } @Override public int getLine() { return 0; } }; assertFalse(html.appliesTo(htmlOrigin, new RawString("foo"))); assertTrue(html.appliesTo(htmlOrigin, "foo")); }
@Override public boolean appliesTo(Origin origin, Object result) { if (result instanceof RawString) { return false; } Optional<Variant> variant = origin.getVariant(); if (variant.isPresent()) { return requiresDefaultEscaping(variant.get()); } return false; }
HtmlEscaper implements ResultMapper { @Override public boolean appliesTo(Origin origin, Object result) { if (result instanceof RawString) { return false; } Optional<Variant> variant = origin.getVariant(); if (variant.isPresent()) { return requiresDefaultEscaping(variant.get()); } return false; } }
HtmlEscaper implements ResultMapper { @Override public boolean appliesTo(Origin origin, Object result) { if (result instanceof RawString) { return false; } Optional<Variant> variant = origin.getVariant(); if (variant.isPresent()) { return requiresDefaultEscaping(variant.get()); } return false; }  }
HtmlEscaper implements ResultMapper { @Override public boolean appliesTo(Origin origin, Object result) { if (result instanceof RawString) { return false; } Optional<Variant> variant = origin.getVariant(); if (variant.isPresent()) { return requiresDefaultEscaping(variant.get()); } return false; }  @Override boolean appliesTo(Origin origin, Object result); @Override String map(Object result, Expression expression); }
HtmlEscaper implements ResultMapper { @Override public boolean appliesTo(Origin origin, Object result) { if (result instanceof RawString) { return false; } Optional<Variant> variant = origin.getVariant(); if (variant.isPresent()) { return requiresDefaultEscaping(variant.get()); } return false; }  @Override boolean appliesTo(Origin origin, Object result); @Override String map(Object result, Expression expression);  }