Skip to content

Instantly share code, notes, and snippets.

@dreadwarrior
Created June 30, 2022 15:29
Show Gist options
  • Save dreadwarrior/3a4c1a8e6bbb3f55179bb7e08a7e3433 to your computer and use it in GitHub Desktop.
Save dreadwarrior/3a4c1a8e6bbb3f55179bb7e08a7e3433 to your computer and use it in GitHub Desktop.
Java Kata: Optional, Stream and List operations
ArrayList<String> list = new ArrayList<>();
String configs = params.getConfigurationIds(); // TODO: CSV list payload
if (configs != null && !configs.trim().isEmpty()) { // TODO: compare with call to StringValidator.isEmptyString() at line 5
// split the list and put all items into the list
if (!StringValidator.isEmptyString(configs)) { // TODO: method body like: string == null || string.trim().isEmpty()
String[] feld = configs.split(",");
if (feld != null) {
if (feld.length > 0) {
for (String dummy : feld) {
String tmp = dummy.trim();
if (tmp.length() > 0) {
list.add(tmp);
}
}
} else { // no comma
list.add(configs);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment