View Javadoc

1   /*
2    PlantUMLDependencyProgrammingLanguageOption.java
3    Creation date : 2/06/2010
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.programminglanguage;
26  
27  import static java.util.Collections.unmodifiableSet;
28  import static net.sourceforge.plantumldependency.cli.main.option.programminglanguage.argument.ProgrammingLanguage.JAVA;
29  import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.SPACE_CHAR;
30  import static net.sourceforge.plantumldependency.commoncli.option.status.OptionStatus.HIDDEN_OPTIONAL_OPTION_STATUS;
31  
32  import java.util.Set;
33  import java.util.TreeSet;
34  
35  import net.sourceforge.plantumldependency.cli.main.option.programminglanguage.argument.PlantUMLDependencyProgrammingLanguageOptionArgument;
36  import net.sourceforge.plantumldependency.cli.main.option.programminglanguage.argument.ProgrammingLanguage;
37  import net.sourceforge.plantumldependency.commoncli.command.CommandLine;
38  import net.sourceforge.plantumldependency.commoncli.exception.CommandLineException;
39  import net.sourceforge.plantumldependency.commoncli.option.AbstractOptionWithArgument;
40  
41  /**
42   * The programming language option, allowing to specify the source file programming language to
43   * analyze. <i>Note : no option should have the same main or secondary names</i>.
44   *
45   * @author Benjamin Croizet (<a href="mailto:graffity2199@yahoo.fr>graffity2199@yahoo.fr</a>)
46   * @since 1.0.0
47   * @version 1.3.0
48   */
49  public class PlantUMLDependencyProgrammingLanguageOption extends AbstractOptionWithArgument < ProgrammingLanguage > {
50  
51      /** Serial version UID. */
52      private static final long serialVersionUID = 1482556561536453265L;
53  
54      /** Option main synopsis. */
55      public static final String OPTION_MAIN_SYNOPSIS = "-l";
56  
57      /** Option synopsis alias. */
58      public static final Set < String > OPTION_SYNOPSIS = unmodifiableSet(new TreeSet < String >());
59  
60      /** The default programming language when the option is not specified. */
61      public static final ProgrammingLanguage DEFAULT_PROGRAMMING_LANGUAGE = JAVA;
62  
63      /**
64       * Default constructor.
65       *
66       * @since 1.0.0
67       */
68      public PlantUMLDependencyProgrammingLanguageOption() {
69          super(OPTION_MAIN_SYNOPSIS, OPTION_SYNOPSIS, new PlantUMLDependencyProgrammingLanguageOptionArgument(true),
70                  new StringBuilder(
71                          "To choose the programming language to reverse engineering. If not specified, the default programming language is \""
72                                  + DEFAULT_PROGRAMMING_LANGUAGE.getName() + "\"."), SPACE_CHAR,
73                  HIDDEN_OPTIONAL_OPTION_STATUS);
74      }
75  
76      /**
77       * {@inheritDoc}
78       *
79       * @since 1.0.0
80       */
81      @Override
82      public String getDefaultArgumentAsStringIfOptionNotSpecified(final CommandLine commandLine)
83              throws CommandLineException {
84          return DEFAULT_PROGRAMMING_LANGUAGE.getName();
85      }
86  
87      /**
88       * {@inheritDoc}
89       *
90       * @since 1.0.0
91       */
92      @Override
93      public String getDefaultArgumentAsStringIfOptionSpecified(final CommandLine commandLine)
94              throws CommandLineException {
95          return DEFAULT_PROGRAMMING_LANGUAGE.getName();
96      }
97  }