Reformatted the codebase
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -11,7 +11,8 @@ class FormUtil {
|
||||
/**
|
||||
* Reads a string from the console.
|
||||
*
|
||||
* @param label Label that is shown before the input
|
||||
* @param label
|
||||
* Label that is shown before the input
|
||||
* @return read string
|
||||
*/
|
||||
static String readString(String label) {
|
||||
@ -19,81 +20,87 @@ class FormUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a string from the console.
|
||||
*
|
||||
* @param label Label that is shown before the input
|
||||
* @param defaultValue the default value in case an empty input is provided
|
||||
* @return read string
|
||||
*/
|
||||
static String readString(String label, String defaultValue) {
|
||||
String ret = null;
|
||||
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
try {
|
||||
System.out.print(label + (!defaultValue.isEmpty() ? "[" + defaultValue + "]" : "") + ": ");
|
||||
ret = stdin.readLine();
|
||||
ret = ret.isEmpty() ? defaultValue : ret;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
* Reads a string from the console.
|
||||
*
|
||||
* @param label
|
||||
* Label that is shown before the input
|
||||
* @param defaultValue
|
||||
* the default value in case an empty input is provided
|
||||
* @return read string
|
||||
*/
|
||||
static String readString(String label, String defaultValue) {
|
||||
String ret = null;
|
||||
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
try {
|
||||
System.out.print(label + (!defaultValue.isEmpty() ? "[" + defaultValue + "]" : "") + ": ");
|
||||
ret = stdin.readLine();
|
||||
ret = ret.isEmpty() ? defaultValue : ret;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a password from the console.
|
||||
*
|
||||
* @return the entered password
|
||||
*/
|
||||
static String readPassword() {
|
||||
String password;
|
||||
static String readPassword() {
|
||||
String password;
|
||||
System.out.print("Password: ");
|
||||
password = String.valueOf(System.console().readPassword());
|
||||
return password;
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* Reads a password from the console.
|
||||
*
|
||||
* @return the entered password
|
||||
*/
|
||||
static String readPassword(String oldPassword) {
|
||||
String password = readPassword();
|
||||
return password.isEmpty() ? oldPassword : password;
|
||||
static String readPassword(String oldPassword) {
|
||||
String password = readPassword();
|
||||
return password.isEmpty() ? oldPassword : password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an integer from the console.
|
||||
*
|
||||
* @param label Label that is shown before the input
|
||||
* @param label
|
||||
* Label that is shown before the input
|
||||
* @return read integer
|
||||
*/
|
||||
static int readInt(String label) {
|
||||
return readInt(label, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an integer from the console.
|
||||
|
||||
/**
|
||||
* Reads an integer from the console.
|
||||
*
|
||||
* @param label Label that is shown before the input
|
||||
* @param defaultValue the default value
|
||||
* @return read integer
|
||||
*/
|
||||
static int readInt(String label, int defaultValue) {
|
||||
int ret = 0;
|
||||
boolean finished = false;
|
||||
String defaultValueStr = defaultValue == -1 ? "" : String.valueOf(defaultValue);
|
||||
|
||||
while(!finished) {
|
||||
String line = readString(label, defaultValueStr);
|
||||
|
||||
try {
|
||||
ret = Integer.parseInt(line);
|
||||
finished = true;
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Invalid input: Please insert a valid number!");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
* @param label
|
||||
* Label that is shown before the input
|
||||
* @param defaultValue
|
||||
* the default value
|
||||
* @return read integer
|
||||
*/
|
||||
static int readInt(String label, int defaultValue) {
|
||||
int ret = 0;
|
||||
boolean finished = false;
|
||||
String defaultValueStr = defaultValue == -1 ? "" : String.valueOf(defaultValue);
|
||||
|
||||
while (!finished) {
|
||||
String line = readString(label, defaultValueStr);
|
||||
|
||||
try {
|
||||
ret = Integer.parseInt(line);
|
||||
finished = true;
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Invalid input: Please insert a valid number!");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user