1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package net.sourceforge.plantumldependency.commoncli.option.impl.verbose;
26
27 import static java.util.Arrays.asList;
28 import static java.util.Collections.unmodifiableSet;
29 import static java.util.logging.Level.INFO;
30 import static java.util.logging.Level.WARNING;
31 import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.SPACE_CHAR;
32 import static net.sourceforge.plantumldependency.common.utils.check.ParameterCheckerUtils.checkNull;
33 import static net.sourceforge.plantumldependency.commoncli.constants.log.ErrorConstants.COMMAND_LINE_NULL_ERROR;
34 import static net.sourceforge.plantumldependency.commoncli.option.status.OptionStatus.ACTIVE_OPTIONAL_OPTION_STATUS;
35
36 import java.util.Set;
37 import java.util.TreeSet;
38 import java.util.logging.Level;
39
40 import net.sourceforge.plantumldependency.commoncli.command.CommandLine;
41 import net.sourceforge.plantumldependency.commoncli.exception.CommandLineException;
42 import net.sourceforge.plantumldependency.commoncli.option.AbstractOptionWithArgument;
43 import net.sourceforge.plantumldependency.commoncli.option.argument.OptionArgument;
44 import net.sourceforge.plantumldependency.commoncli.option.argument.impl.log.LevelOptionArgumentImpl;
45 import net.sourceforge.plantumldependency.commoncli.option.status.OptionStatus;
46
47
48
49
50
51
52
53
54
55 public class VerboseLevelOption extends AbstractOptionWithArgument < Level > {
56
57
58 private static final long serialVersionUID = -3207782116090972597L;
59
60
61 public static final String OPTION_MAIN_SYNOPSIS = "-v";
62
63
64 public static final Set < String > OPTION_SYNOPSIS = unmodifiableSet(new TreeSet < String >(
65 asList(new String[] {"--verbose"})));
66
67
68
69
70
71
72 public VerboseLevelOption() {
73 this(new LevelOptionArgumentImpl(false), new StringBuilder("To display log information."), SPACE_CHAR,
74 ACTIVE_OPTIONAL_OPTION_STATUS);
75 }
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 public VerboseLevelOption(final OptionArgument < Level > argument, final StringBuilder fullOptionDescription,
94 final String valSepararator, final OptionStatus optionStatus) {
95 super(OPTION_MAIN_SYNOPSIS, OPTION_SYNOPSIS, argument, fullOptionDescription, valSepararator, optionStatus);
96 }
97
98
99
100
101
102
103 @Override
104 public VerboseLevelOption deepClone() {
105 return (VerboseLevelOption) super.deepClone();
106 }
107
108
109
110
111
112
113 @Override
114 public String getDefaultArgumentAsStringIfOptionNotSpecified(final CommandLine commandLine)
115 throws CommandLineException {
116 checkNull(commandLine, COMMAND_LINE_NULL_ERROR);
117
118 return WARNING.getName();
119 }
120
121
122
123
124
125
126 @Override
127 public String getDefaultArgumentAsStringIfOptionSpecified(final CommandLine commandLine)
128 throws CommandLineException {
129 checkNull(commandLine, COMMAND_LINE_NULL_ERROR);
130
131 return INFO.getName();
132 }
133 }