Skip to content

Commit

Permalink
Merge pull request #760 from csmith/master
Browse files Browse the repository at this point in the history
Add "unstyled" formatter func to strip control codes.
  • Loading branch information
greboid committed Jan 2, 2017
2 parents bd00c55 + 65174b6 commit 484ebba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Expand Up @@ -54,6 +54,7 @@ public EventPropertyManager() {
functions.put("lowercase", String::toLowerCase);
functions.put("trim", String::trim);
functions.put("bracketed", s -> Strings.isNullOrEmpty(s) ? "" : " (" + s + ')');
functions.put("unstyled", new StyledMessageUtils()::stripControlCodes);
}

public <S> Optional<Object> getProperty(final S object, final Class<? extends S> type, final String property) {
Expand Down
Expand Up @@ -56,6 +56,7 @@ public void testAppliesBuiltInFunctions() {
assertEquals("test 123", manager.applyFunction("TeSt 123", "lowercase"));
assertEquals("TEST 123", manager.applyFunction("TeSt 123", "uppercase"));
assertEquals("TeSt 123", manager.applyFunction(" TeSt 123 ", "trim"));
assertEquals("TeSt 123", manager.applyFunction("\2TeSt \4FFFFFF123", "unstyled"));
}

@Test
Expand Down

0 comments on commit 484ebba

Please sign in to comment.