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.output;
26
27 import static java.util.Arrays.asList;
28 import static java.util.Collections.unmodifiableSet;
29 import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.SPACE_CHAR;
30 import static net.sourceforge.plantumldependency.common.constants.CommonFileConstants.TXT_EXTENSION;
31 import static net.sourceforge.plantumldependency.common.utils.check.ParameterCheckerUtils.checkNull;
32 import static net.sourceforge.plantumldependency.commoncli.constants.log.ErrorConstants.COMMAND_LINE_NULL_ERROR;
33 import static net.sourceforge.plantumldependency.commoncli.option.status.OptionStatus.ACTIVE_MANDATORY_OPTION_STATUS;
34
35 import java.io.File;
36 import java.util.Date;
37 import java.util.Set;
38 import java.util.TreeSet;
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.file.ExistingOrNotFileOptionArgumentImpl;
45 import net.sourceforge.plantumldependency.commoncli.option.status.OptionStatus;
46
47
48
49
50
51
52
53
54
55
56 public class OutputOption extends AbstractOptionWithArgument < File > {
57
58
59 private static final long serialVersionUID = 313893193517910913L;
60
61
62 public static final String OPTION_MAIN_SYNOPSIS = "-o";
63
64
65 public static final Set < String > OPTION_SYNOPSIS = unmodifiableSet(new TreeSet < String >(
66 asList(new String[] {"--output"})));
67
68
69
70
71
72
73 public OutputOption() {
74 this(new ExistingOrNotFileOptionArgumentImpl(true), new StringBuilder("To output file path"), SPACE_CHAR,
75 ACTIVE_MANDATORY_OPTION_STATUS);
76 }
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94 public OutputOption(final OptionArgument < File > argument, final StringBuilder fullOptionDescription,
95 final String valSepararator, final OptionStatus optionStatus) {
96 super(OPTION_MAIN_SYNOPSIS, OPTION_SYNOPSIS, argument, fullOptionDescription, valSepararator, optionStatus);
97 }
98
99
100
101
102
103
104 @Override
105 public String getDefaultArgumentAsStringIfOptionNotSpecified(final CommandLine commandLine)
106 throws CommandLineException {
107 checkNull(commandLine, COMMAND_LINE_NULL_ERROR);
108
109 return new Date().getTime() + TXT_EXTENSION;
110 }
111
112
113
114
115
116
117 @Override
118 public String getDefaultArgumentAsStringIfOptionSpecified(final CommandLine commandLine)
119 throws CommandLineException {
120 checkNull(commandLine, COMMAND_LINE_NULL_ERROR);
121
122 return new Date().getTime() + TXT_EXTENSION;
123 }
124 }