TsIdentifierFilter extends Filter { @Override public Object apply(Object value, Object... params) { return TYPESCRIPT_KEYWORDS.contains(value) ? "_" + value : value; } TsIdentifierFilter(); @Override Object apply(Object value, Object... params); static final Set<String> TYPESCRIPT_KEYWORDS; }
@Test public void testApply_sanitizesValueIfTypeScriptKeyword() { TsIdentifierFilter filter = new TsIdentifierFilter(); assertEquals("_number", filter.apply("number")); }
@Test public void testApply_doesNotSanitizeNonTypeScriptKeywords() { TsIdentifierFilter filter = new TsIdentifierFilter(); assertEquals("foobar", filter.apply("foobar")); }