View Javadoc

1   /*
2    OptionArgument.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.commoncli.option.argument;
26  
27  import java.io.Serializable;
28  
29  import net.sourceforge.plantumldependency.common.clone.DeepCloneable;
30  import net.sourceforge.plantumldependency.commoncli.exception.CommandLineException;
31  
32  /**
33   * The interface which describes an option argument, which has the template type.
34   *
35   * @param <A>
36   *            the argument type to parse.
37   * @author Benjamin Croizet (<a href="mailto:graffity2199@yahoo.fr>graffity2199@yahoo.fr</a>)
38   * @since 1.3.0
39   * @version 1.3.0
40   */
41  public interface OptionArgument < A > extends Comparable < OptionArgument < A > >, Serializable,
42          DeepCloneable < OptionArgument < A > > {
43  
44      /**
45       * Gets the full argument usage description, i.e. the full synopsis of how the argument is used
46       * and the argument's description.
47       * <p>
48       * For instance it can be :<br>
49       * - <i>"FILE specifies a valid file path, not a directory. It can be absolute or relative."</i>
50       * <br>
51       * - <i>"INTEGER specifies an integer, positive or negative."</i>
52       * </p>
53       *
54       * @return the main option usage as a {@link StringBuilder}.
55       * @since 1.3.0
56       */
57      StringBuilder getFullUsageDescription();
58  
59      /**
60       * Gets the main argument usage, i.e. the summary synopsis of how the argument is used.
61       * <p>
62       * For instance it can be :<br>
63       * - <i>"FILE"</i><br>
64       * - <i>"[INTEGER]"</i>
65       * </p>
66       *
67       * @return the main option usage as a {@link StringBuilder}.
68       * @since 1.3.0
69       */
70      StringBuilder getMainUsage();
71  
72      /**
73       * Gets the boolean which tells if the argument is mandatory.
74       *
75       * @return <code>true</code> if the argument is mandatory, <code>false</code> otherwise.
76       * @since 1.3.0
77       */
78      boolean isMandatory();
79  
80      /**
81       * Reads and parses the {@link String} argument.
82       *
83       * @param argument
84       *            the argument to parse, mustn't be <code>null</code>.
85       * @return the argument instance following the template type.
86       * @throws CommandLineException
87       *             if any error occurs while parsing the argument.
88       * @since 1.3.0
89       */
90      A parseArgument(String argument) throws CommandLineException;
91  }