Skip to content

Commit

Permalink
add static final variable for string comparison
Browse files Browse the repository at this point in the history
Signed-off-by: Kat Shen <[email protected]>
  • Loading branch information
shenkw1 committed Jul 5, 2023
1 parent 72cc32f commit 204817b
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class KeyValueProcessor extends AbstractProcessor<Record<Event>, Record<E
private final Pattern keyValueDelimiterPattern;
private final Set<String> includeKeysSet = new HashSet<String>();
private final Set<String> validTransformOptionSet = Set.of("", "lowercase", "uppercase", "capitalize");
private final String LOWERCASE_KEY = "lowercase";
private final String UPPERCASE_KEY = "uppercase";
private final String CAPITALIZE_KEY = "capitalize";

@DataPrepperPluginConstructor
public KeyValueProcessor(final PluginMetrics pluginMetrics, final KeyValueProcessorConfig keyValueProcessorConfig) {
Expand Down Expand Up @@ -182,11 +185,11 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor
}

private String transformKey(String key) {
if(keyValueProcessorConfig.getTransformKey().equals("lowercase")) {
if(keyValueProcessorConfig.getTransformKey().equals(LOWERCASE_KEY)) {
key = key.toLowerCase();
} else if(keyValueProcessorConfig.getTransformKey().equals("uppercase")) {
} else if(keyValueProcessorConfig.getTransformKey().equals(UPPERCASE_KEY)) {
key = key.substring(0, 1).toUpperCase() + key.substring(1);
} else if(keyValueProcessorConfig.getTransformKey().equals("capitalize")) {
} else if(keyValueProcessorConfig.getTransformKey().equals(CAPITALIZE_KEY)) {
key = key.toUpperCase();
}
return key;
Expand Down

0 comments on commit 204817b

Please sign in to comment.