View Javadoc

1   /*
2    PlantUMLDependencyDisplayPackageNameOption.java
3    Creation date : 31/05/2014
4    Copyright © Benjamin Croizet (graffity2199@yahoo.fr)
5   
6    This program is free software; you can redistribute it and/or
7    modify it under the terms of the GNU General Public License
8    or GNU Lesser General Public License as published by the
9    Free Software Foundation; either version 3 of the License,
10   or (at your option) any later version.
11  
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16  
17   You should have received copies of the GNU General Public License
18   and GNU Lesser General Public License along with this program;
19   if not, write to the Free Software Foundation, Inc.,
20   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21   http://www.fsf.org/licensing/licenses/gpl.html
22   http://www.gnu.org/licenses/lgpl.html
23   */
24  
25  package net.sourceforge.plantumldependency.cli.main.option.display.packagename;
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_DISPLAY_PACKAGE_NAME_OPTIONS_STRING;
30  import static net.sourceforge.plantumldependency.cli.constants.PlantUMLDependencyConstants.NATIVE_DEPENDENCY_PACKAGE_NAME;
31  import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.SPACE_CHAR;
32  import static net.sourceforge.plantumldependency.commoncli.option.status.OptionStatus.ACTIVE_OPTIONAL_OPTION_STATUS;
33  
34  import java.util.Set;
35  import java.util.TreeSet;
36  import java.util.regex.Pattern;
37  
38  import net.sourceforge.plantumldependency.cli.main.option.display.packagename.argument.PlantUMLDependencyDisplayPackageNameOptionArgument;
39  import net.sourceforge.plantumldependency.commoncli.command.CommandLine;
40  import net.sourceforge.plantumldependency.commoncli.exception.CommandLineException;
41  import net.sourceforge.plantumldependency.commoncli.option.AbstractOptionWithArgument;
42  
43  /**
44   * The display package name option, telling the program what to display in the generated file.
45   * <i>Note : no option should have the same main or secondary names</i>.
46   *
47   * @author Benjamin Croizet (<a href="mailto:graffity2199@yahoo.fr>graffity2199@yahoo.fr</a>)
48   * @since 1.4.0
49   * @version 1.4.0
50   */
51  public class PlantUMLDependencyDisplayPackageNameOption extends AbstractOptionWithArgument < Pattern > {
52  
53      /** Serial version UID. */
54      private static final long serialVersionUID = 6636249105521044787L;
55  
56      /** Option main synopsis. */
57      public static final String OPTION_MAIN_SYNOPSIS = "-dp";
58  
59      /** Option synopsis alias. */
60      public static final Set < String > OPTION_SYNOPSIS = unmodifiableSet(new TreeSet < String >(
61              asList(new String[] {"--display-package-name"})));
62  
63      /**
64       * Default constructor.
65       *
66       * @since 1.4.0
67       */
68      public PlantUMLDependencyDisplayPackageNameOption() {
69          super(
70                  OPTION_MAIN_SYNOPSIS,
71                  OPTION_SYNOPSIS,
72                  new PlantUMLDependencyDisplayPackageNameOptionArgument(),
73                  new StringBuilder(
74                          "To specify class diagram objects to display following their package name. If not specified, the default is \""
75                                  + DEFAULT_DISPLAY_PACKAGE_NAME_OPTIONS_STRING
76                                  + "\". Note : native calls which are represented by the \""
77                                  + NATIVE_DEPENDENCY_PACKAGE_NAME
78                                  + "\" package name can also be matched by this regular expression even if it is a fictive dependency."),
79                  SPACE_CHAR, ACTIVE_OPTIONAL_OPTION_STATUS);
80      }
81  
82      /**
83       * {@inheritDoc}
84       *
85       * @since 1.4.0
86       */
87      @Override
88      public String getDefaultArgumentAsStringIfOptionNotSpecified(final CommandLine commandLine)
89              throws CommandLineException {
90          return DEFAULT_DISPLAY_PACKAGE_NAME_OPTIONS_STRING;
91      }
92  
93      /**
94       * {@inheritDoc}
95       *
96       * @since 1.4.0
97       */
98      @Override
99      public String getDefaultArgumentAsStringIfOptionSpecified(final CommandLine commandLine)
100             throws CommandLineException {
101         return DEFAULT_DISPLAY_PACKAGE_NAME_OPTIONS_STRING;
102     }
103 }