reformat file

This commit is contained in:
Jonathan Shook 2020-07-20 12:41:55 -05:00
parent e673197161
commit 2091c5ad5a

View File

@ -8,10 +8,9 @@ import java.util.*;
import java.util.function.Function;
/**
* Encapsulate Command parsing and structure for the NoSQLBench command line.
* Commands always have a name, sometimes have a list of positional arguments,
* and sometimes have a map of named parameters.
* An example of a command tha thas both would look like {@code script test.js p1=v1}
* Encapsulate Command parsing and structure for the NoSQLBench command line. Commands always have a name, sometimes
* have a list of positional arguments, and sometimes have a map of named parameters. An example of a command tha thas
* both would look like {@code script test.js p1=v1}
*/
public class Cmd {
@ -72,8 +71,9 @@ public class Cmd {
public static Arg<String> of(String name) {
return new Arg<>(name, s -> s, false);
}
public static Arg<String> ofFreeform(String name) {
return new Arg<>(name, s->s, true);
return new Arg<>(name, s -> s, true);
}
}
@ -109,7 +109,7 @@ public class Cmd {
for (String value : getParams().values()) {
String trimmed = ((value.startsWith("'") && value.endsWith("'"))
|| (value.startsWith("\"")) && value.endsWith("\"")) ?
value.substring(1,value.length()-1) : value;
value.substring(1, value.length() - 1) : value;
sb.append("'").append(trimmed).append("'").append(",");
}
sb.setLength(sb.length() - 1);
@ -179,9 +179,9 @@ public class Cmd {
String key = entries.getKey();
String value = sanitizeQuotes(entries.getValue());
if (oneline) {
l.add("'" + key + "':'"+value+"'");
l.add("'" + key + "':'" + value + "'");
} else {
l.add(" '"+key+"': " + " ".repeat(klen - key.length()) + "'" + value + "'");
l.add(" '" + key + "': " + " ".repeat(klen - key.length()) + "'" + value + "'");
}
}
return "{" + (oneline ? "" : "\n") + String.join(",\n", l) + (oneline ? "}" : "\n}");
@ -189,10 +189,10 @@ public class Cmd {
private static String sanitizeQuotes(String value) {
if (value.startsWith("'") && value.endsWith("'")) {
return value.substring(1,value.length()-1);
return value.substring(1, value.length() - 1);
}
if (value.startsWith("\"") && value.endsWith("\"")) {
return value.substring(1,value.length()-1);
return value.substring(1, value.length() - 1);
}
return value;