1 /* 2 YesNoBoolean.java 3 Creation date : 01/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.common.utils.bool; 26 27 /** 28 * This enumeration type lists "yes" and "no" string. 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 YesNoBoolean { 35 36 /** The "yes" boolean. */ 37 YES(true, 1), 38 /** The "no" boolean. */ 39 NO(false, 0); 40 41 /** The boolean value which usually represents the enum variable. */ 42 private boolean booleanValue; 43 44 /** The integer value which usually represents the enum variable. */ 45 private int intRepresentation; 46 47 /** 48 * Default constructor with the boolean value. 49 * 50 * @param booleanVal 51 * The boolean value to affect. 52 * @param integerRepresentation 53 * The integer representation to affect. 54 * @since 1.3.0 55 */ 56 private YesNoBoolean(final boolean booleanVal, final int integerRepresentation) { 57 setBooleanValue(booleanVal); 58 setIntRepresentation(integerRepresentation); 59 } 60 61 /** 62 * Gets the value of booleanValue. 63 * 64 * @return the value of booleanValue. 65 * @since 1.3.0 66 */ 67 public boolean getBooleanValue() { 68 return booleanValue; 69 } 70 71 /** 72 * Gets the value of intRepresentation. 73 * 74 * @return the value of intRepresentation. 75 * @since 1.3.0 76 */ 77 public int getIntRepresentation() { 78 return intRepresentation; 79 } 80 81 /** 82 * Gets the value of intRepresentation as a String. 83 * 84 * @return the value of intRepresentation as a String. 85 * @see #getIntRepresentation() 86 * @since 1.3.0 87 */ 88 public String getIntRepresentationAsString() { 89 return Integer.toString(intRepresentation); 90 } 91 92 /** 93 * Sets the value of booleanValue. 94 * 95 * @param value 96 * the booleanValue to set. 97 * @see #getBooleanValue() 98 * @since 1.3.0 99 */ 100 private void setBooleanValue(final boolean value) { 101 booleanValue = value; 102 } 103 104 /** 105 * Sets the value of intRepresentation. 106 * 107 * @param value 108 * the intRepresentation to set. 109 * @see #getIntRepresentation() 110 * @since 1.3.0 111 */ 112 private void setIntRepresentation(final int value) { 113 intRepresentation = value; 114 } 115 116 /** 117 * {@inheritDoc} 118 * 119 * @since 1.3.0 120 */ 121 @Override 122 public String toString() { 123 final String str = super.toString(); 124 return str.toLowerCase(); 125 } 126 }