View Javadoc

1   /*
2    PlantUMLDependencyExcludeOption.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.exclude;
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_EXCLUDE_OPTIONS;
30  import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.SPACE_CHAR;
31  import static net.sourceforge.plantumldependency.commoncli.option.status.OptionStatus.ACTIVE_OPTIONAL_OPTION_STATUS;
32  
33  import java.util.Set;
34  import java.util.TreeSet;
35  
36  import net.sourceforge.plantumldependency.commoncli.command.CommandLine;
37  import net.sourceforge.plantumldependency.commoncli.exception.CommandLineException;
38  import net.sourceforge.plantumldependency.commoncli.option.AbstractOptionWithArgument;
39  import net.sourceforge.plantumldependency.commoncli.option.argument.impl.filepattern.ExcludeFilePatternOptionArgumentImpl;
40  
41  import org.apache.tools.ant.types.FileSet;
42  
43  /**
44   * The exclude option, allowing to specify an exclude file pattern, like ANT. <i>Note : no option
45   * 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.0.0
49   * @version 1.4.0
50   */
51  public class PlantUMLDependencyExcludeOption extends AbstractOptionWithArgument < FileSet > {
52  
53      /** Serial version UID. */
54      private static final long serialVersionUID = -4187623575754105884L;
55  
56      /** Option main synopsis. */
57      public static final String OPTION_MAIN_SYNOPSIS = "-e";
58  
59      /** Option synopsis alias. */
60      public static final Set < String > OPTION_SYNOPSIS = unmodifiableSet(new TreeSet < String >(
61              asList(new String[] {"--exclude"})));
62  
63      /**
64       * Default constructor.
65       *
66       * @since 1.0.0
67       */
68      public PlantUMLDependencyExcludeOption() {
69          super(OPTION_MAIN_SYNOPSIS, OPTION_SYNOPSIS, new ExcludeFilePatternOptionArgumentImpl(true), new StringBuilder(
70                  "To exclude files that match the provided pattern. If not specified, the default pattern is \""
71                          + DEFAULT_EXCLUDE_OPTIONS + "\"."), SPACE_CHAR, ACTIVE_OPTIONAL_OPTION_STATUS);
72      }
73  
74      /**
75       * {@inheritDoc}
76       *
77       * @since 1.0.0
78       */
79      @Override
80      public String getDefaultArgumentAsStringIfOptionNotSpecified(final CommandLine commandLine)
81              throws CommandLineException {
82          return DEFAULT_EXCLUDE_OPTIONS;
83      }
84  
85      /**
86       * {@inheritDoc}
87       *
88       * @since 1.0.0
89       */
90      @Override
91      public String getDefaultArgumentAsStringIfOptionSpecified(final CommandLine commandLine)
92              throws CommandLineException {
93          return DEFAULT_EXCLUDE_OPTIONS;
94      }
95  }