|
10 | 10 | */
|
11 | 11 | class OutputChoice {
|
12 | 12 |
|
13 |
| - enum OutputChoiceType { |
14 |
| - SYS_OUT, CACHED_SYS_OUT, SYS_ERR, CACHED_SYS_ERR, FILE; |
15 |
| - } |
16 |
| - |
17 |
| - final OutputChoiceType outputChoiceType; |
18 |
| - final PrintStream targetPrintStream; |
19 |
| - |
20 |
| - OutputChoice(OutputChoiceType outputChoiceType) { |
21 |
| - if (outputChoiceType == OutputChoiceType.FILE) { |
22 |
| - throw new IllegalArgumentException(); |
23 |
| - } |
24 |
| - this.outputChoiceType = outputChoiceType; |
25 |
| - if (outputChoiceType == OutputChoiceType.CACHED_SYS_OUT) { |
26 |
| - this.targetPrintStream = System.out; |
27 |
| - } else if (outputChoiceType == OutputChoiceType.CACHED_SYS_ERR) { |
28 |
| - this.targetPrintStream = System.err; |
29 |
| - } else { |
30 |
| - this.targetPrintStream = null; |
31 |
| - } |
32 |
| - } |
33 |
| - |
34 |
| - OutputChoice(PrintStream printStream) { |
35 |
| - this.outputChoiceType = OutputChoiceType.FILE; |
36 |
| - this.targetPrintStream = printStream; |
37 |
| - } |
38 |
| - |
39 |
| - PrintStream getTargetPrintStream() { |
40 |
| - switch (outputChoiceType) { |
41 |
| - case SYS_OUT: |
42 |
| - return System.out; |
43 |
| - case SYS_ERR: |
44 |
| - return System.err; |
45 |
| - case CACHED_SYS_ERR: |
46 |
| - case CACHED_SYS_OUT: |
47 |
| - case FILE: |
48 |
| - return targetPrintStream; |
49 |
| - default: |
50 |
| - throw new IllegalArgumentException(); |
51 |
| - } |
52 |
| - |
53 |
| - } |
| 13 | + enum OutputChoiceType { |
| 14 | + SYS_OUT, CACHED_SYS_OUT, SYS_ERR, CACHED_SYS_ERR, FILE; |
| 15 | + } |
| 16 | + |
| 17 | + final OutputChoiceType outputChoiceType; |
| 18 | + final PrintStream targetPrintStream; |
| 19 | + |
| 20 | + OutputChoice(OutputChoiceType outputChoiceType) { |
| 21 | + if (outputChoiceType == OutputChoiceType.FILE) { |
| 22 | + throw new IllegalArgumentException(); |
| 23 | + } |
| 24 | + this.outputChoiceType = outputChoiceType; |
| 25 | + if (outputChoiceType == OutputChoiceType.CACHED_SYS_OUT) { |
| 26 | + this.targetPrintStream = System.out; |
| 27 | + } else if (outputChoiceType == OutputChoiceType.CACHED_SYS_ERR) { |
| 28 | + this.targetPrintStream = System.err; |
| 29 | + } else { |
| 30 | + this.targetPrintStream = null; |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + OutputChoice(PrintStream printStream) { |
| 35 | + this.outputChoiceType = OutputChoiceType.FILE; |
| 36 | + this.targetPrintStream = printStream; |
| 37 | + } |
| 38 | + |
| 39 | + PrintStream getTargetPrintStream() { |
| 40 | + switch (outputChoiceType) { |
| 41 | + case SYS_OUT: |
| 42 | + return System.out; |
| 43 | + case SYS_ERR: |
| 44 | + return System.err; |
| 45 | + case CACHED_SYS_ERR: |
| 46 | + case CACHED_SYS_OUT: |
| 47 | + case FILE: |
| 48 | + return targetPrintStream; |
| 49 | + default: |
| 50 | + throw new IllegalArgumentException(); |
| 51 | + } |
| 52 | + |
| 53 | + } |
54 | 54 |
|
55 | 55 | }
|
0 commit comments