View Javadoc

1   /*
2    OptionStatus.java
3    Creation date : 5/10/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.status;
26  
27  /**
28   * This enumeration contains all option status.
29   *
30   * @author Benjamin Croizet (<a href="mailto:graffity2199@yahoo.fr>graffity2199@yahoo.fr</a>)
31   * @since 1.3.0
32   * @version 1.3.0
33   */
34  public enum OptionStatus {
35  
36      /** The status which makes an option active and mandatory. */
37      ACTIVE_MANDATORY_OPTION_STATUS(true, true),
38      /** The status which makes an option active and optional. */
39      ACTIVE_OPTIONAL_OPTION_STATUS(false, true),
40      /** The status which makes an option inactive and optional. */
41      INACTIVE_OPTIONAL_OPTION_STATUS(false, false),
42      /** The status which makes an option hidden and optional. */
43      HIDDEN_OPTIONAL_OPTION_STATUS(false, true);
44  
45      /** The boolean telling if the option is mandatory or not. */
46      private boolean mandatory;
47  
48      /**
49       * The boolean telling if the option is considered active, meaning it has to be taken in the
50       * command line when parsing it.
51       */
52      private boolean active;
53  
54      /**
55       * Full constructor.
56       *
57       * @param optionIsMandatory
58       *            <code>true</code> if the option is mandatory, <code>false</code> otherwise.
59       * @param isActive
60       *            <code>true</code> if the option is considered active, meaning it has to be taken
61       *            in the command line when parsing it, <code>false</code> otherwise.
62       * @since 1.3.0
63       */
64      private OptionStatus(final boolean optionIsMandatory, final boolean isActive) {
65          setMandatory(optionIsMandatory);
66          setActive(isActive);
67      }
68  
69      /**
70       * Gets the value of <code>active</code>.
71       *
72       * @return the value of <code>active</code>.
73       * @since 1.3.0
74       */
75      public boolean isActive() {
76          return active;
77      }
78  
79      /**
80       * Gets the boolean which tells if the option is mandatory.
81       *
82       * @return <code>true</code> if the option is mandatory, <code>false</code> otherwise.
83       * @since 1.3.0
84       */
85      public boolean isMandatory() {
86          return mandatory;
87      }
88  
89      /**
90       * Sets the value of <code>active</code>.
91       *
92       * @param value
93       *            the <code>active</code> to set, can be <code>null</code>.
94       * @see #isActive()
95       * @since 1.3.0
96       */
97      private void setActive(final boolean value) {
98          active = value;
99      }
100 
101     /**
102      * Sets the value of <code>mandatory</code>.
103      *
104      * @param value
105      *            the <code>mandatory</code> to set, can be <code>null</code>.
106      * @see #isMandatory()
107      * @since 1.3.0
108      */
109     private void setMandatory(final boolean value) {
110         mandatory = value;
111     }
112 }