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.cli.main.option.include;
26
27 import static java.util.Arrays.asList;
28 import static java.util.Collections.unmodifiableSet;
29 import static net.sourceforge.plantumldependency.cli.constants.PlantUMLDependencyConstants.DEFAULT_INCLUDE_OPTIONS;
30 import static net.sourceforge.plantumldependency.cli.constants.log.ErrorConstants.PROGRAMMING_LANGUAGE_OPTION_NULL_ERROR;
31 import static net.sourceforge.plantumldependency.cli.main.option.programminglanguage.PlantUMLDependencyProgrammingLanguageOption.DEFAULT_PROGRAMMING_LANGUAGE;
32 import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.SPACE_CHAR;
33 import static net.sourceforge.plantumldependency.common.utils.check.ParameterCheckerUtils.checkNull;
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
39 import net.sourceforge.plantumldependency.cli.main.option.programminglanguage.PlantUMLDependencyProgrammingLanguageOption;
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.impl.filepattern.IncludeFilePatternOptionArgumentImpl;
44
45 import org.apache.tools.ant.types.FileSet;
46
47
48
49
50
51
52
53
54
55 public class PlantUMLDependencyIncludeOption extends AbstractOptionWithArgument < FileSet > {
56
57
58 private static final long serialVersionUID = -7573306659605231967L;
59
60
61 public static final String OPTION_MAIN_SYNOPSIS = "-i";
62
63
64 public static final Set < String > OPTION_SYNOPSIS = unmodifiableSet(new TreeSet < String >(
65 asList(new String[] {"--include"})));
66
67
68 private PlantUMLDependencyProgrammingLanguageOption programmingLanguageOption;
69
70
71
72
73
74
75
76
77
78 public PlantUMLDependencyIncludeOption(final PlantUMLDependencyProgrammingLanguageOption programmingLanguageOpt) {
79 super(OPTION_MAIN_SYNOPSIS, OPTION_SYNOPSIS, new IncludeFilePatternOptionArgumentImpl(true), new StringBuilder(
80 "To include files that match the provided pattern. If not specified, the default pattern is \"**/*."
81 + DEFAULT_PROGRAMMING_LANGUAGE.getName() + "\"."), SPACE_CHAR, ACTIVE_OPTIONAL_OPTION_STATUS);
82 setProgrammingLanguageOption(programmingLanguageOpt);
83
84
85
86
87
88
89
90
91
92
93
94
95 }
96
97
98
99
100
101
102 @Override
103 public String getDefaultArgumentAsStringIfOptionNotSpecified(final CommandLine commandLine)
104 throws CommandLineException {
105 return DEFAULT_INCLUDE_OPTIONS
106 + getProgrammingLanguageOption().findAndParseArgumentOrGetDefaultArgument(commandLine).getName();
107 }
108
109
110
111
112
113
114 @Override
115 public String getDefaultArgumentAsStringIfOptionSpecified(final CommandLine commandLine)
116 throws CommandLineException {
117 return DEFAULT_INCLUDE_OPTIONS
118 + getProgrammingLanguageOption().findAndParseArgumentOrGetDefaultArgument(commandLine).getName();
119 }
120
121
122
123
124
125
126
127
128 private PlantUMLDependencyProgrammingLanguageOption getProgrammingLanguageOption() {
129 return programmingLanguageOption;
130 }
131
132
133
134
135
136
137
138
139
140 private void setProgrammingLanguageOption(final PlantUMLDependencyProgrammingLanguageOption value) {
141 checkNull(value, PROGRAMMING_LANGUAGE_OPTION_NULL_ERROR);
142
143 programmingLanguageOption = value;
144 }
145 }