Github user mattf-horton commented on a diff in the pull request: https://github.com/apache/incubator-metron/pull/516#discussion_r110290675 --- Diff: metron-platform/metron-common/src/main/java/org/apache/metron/common/dsl/functions/StringFunctions.java --- @@ -343,4 +343,89 @@ public Object apply(List<Object> args) { return String.format(format, formatArgs); } } + + @Stellar( name="CHOP" + , description = "Remove the last character from a String" + , params = { "the String to chop last character from, may be null"} + , returns = "String without last character, null if null String input" + ) + public static class chop extends BaseStellarFunction { + + @Override + public Object apply(List<Object> strings) { + + if(strings.size() == 0) { + throw new IllegalArgumentException("[CHOP] missing argument: string to be chopped"); + } + + String chop = StringUtils.chop((String) strings.get(0)); + return chop; + } + } + + @Stellar( name = "PREPENDIFMISSING" + , description = "Prepends the prefix to the start of the string if the string does not already start with any of the prefixes" + , params = { "str - The string.", "prefix - The prefix to prepend to the start of the string", "prefixes - Additional prefixes that are valid" } + , returns = "A new String if prefix was prepended, the same string otherwise." + ) + public static class prependifmissing extends BaseStellarFunction { + + @Override + public Object apply(List<Object> strings) { + + String prefixed; + switch (strings.size()) { + case 2: prefixed = org.apache.commons.lang3.StringUtils.prependIfMissing((String) strings.get(0), (String) strings.get(1)); --- End diff -- It's not a bad thing to give the FQ class name for StringUtils -- I initially thought line 361 referred to metron-common/src/main/java/org/apache/metron/common/utils/StringUtils.java, and this makes clear it doesn't. But why use commons.lang.StringUtils in line 361 and commons.lang3.StringUtils here? Shouldn't they all just use lang3? And you should *either* import the library and refer to it by short name, or not import it and refer to it by FQ class name, I think.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---