follow java conventions for enums

This commit is contained in:
Ceki Gulcu 2017-01-11 18:56:49 +01:00
parent 69be5f7f98
commit b8b881b739
2 changed files with 9 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import java.io.PrintStream;
class OutputChoice {
enum OutputChoiceType {
SysOut, SysErr, File;
SYS_OUT, SYS_ERR, FILE;
}
@ -20,7 +20,7 @@ class OutputChoice {
final PrintStream targetPrintStream;
OutputChoice(OutputChoiceType outputChoiceType) {
if (outputChoiceType == OutputChoiceType.File) {
if (outputChoiceType == OutputChoiceType.FILE) {
throw new IllegalArgumentException();
}
this.outputChoiceType = outputChoiceType;
@ -28,17 +28,17 @@ class OutputChoice {
}
OutputChoice(PrintStream printStream) {
this.outputChoiceType = OutputChoiceType.File;
this.outputChoiceType = OutputChoiceType.FILE;
this.targetPrintStream = printStream;
}
PrintStream getTargetPrintStream() {
switch (outputChoiceType) {
case SysOut:
case SYS_OUT:
return System.out;
case SysErr:
case SYS_ERR:
return System.err;
case File:
case FILE:
return targetPrintStream;
default:
throw new IllegalArgumentException();

View File

@ -224,9 +224,9 @@ public class SimpleLogger extends MarkerIgnoringBase {
private static OutputChoice computeOutputChoice(String logFile) {
if ("System.err".equalsIgnoreCase(logFile))
return new OutputChoice(OutputChoiceType.SysErr);
return new OutputChoice(OutputChoiceType.SYS_ERR);
else if ("System.out".equalsIgnoreCase(logFile)) {
return new OutputChoice(OutputChoiceType.SysOut);
return new OutputChoice(OutputChoiceType.SYS_OUT);
} else {
try {
FileOutputStream fos = new FileOutputStream(logFile);
@ -234,7 +234,7 @@ public class SimpleLogger extends MarkerIgnoringBase {
return new OutputChoice(printStream);
} catch (FileNotFoundException e) {
Util.report("Could not open [" + logFile + "]. Defaulting to System.err", e);
return new OutputChoice(OutputChoiceType.SysErr);
return new OutputChoice(OutputChoiceType.SYS_ERR);
}
}
}