KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mdarad > framework > enumeration > AllowableValue


1 /*
2     Mdarad-Toolobox is a collection of tools for Architected RAD
3     (Rapid Application Development) based on an MDA approach.
4     The toolbox contains frameworks and generators for many environments
5     (JAVA, J2EE, Hibernate, .NET, C++, etc.) which allow to generate
6     applications from a design Model
7     Copyright (C) 2004-2005 Elapse Technologies Inc.
8
9     This library is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public
11     License as published by the Free Software Foundation; either
12     version 2.1 of the License, or (at your option) any later version.
13
14     This library is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17     General Public License for more details.
18
19     You should have received a copy of the GNU General Public
20     License along with this library; if not, write to the Free Software
21     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */

23 package org.mdarad.framework.enumeration;
24
25 import java.io.Serializable JavaDoc;
26
27 /**
28  * This class represents a enumeration value needed to create an enumeration
29  * class (not yet supported by the MDARAD GENERATOR)
30  *
31  * @author Philippe Brouillette
32  * @version 1.0
33  */

34 public abstract class AllowableValue implements Serializable JavaDoc {
35
36     /**
37      * Public constructor that initializes the value and the
38      * label of the allowable value
39      * @param value String that represents the value
40      * @param label Label associated to the allowable value
41      */

42     public AllowableValue(String JavaDoc value, String JavaDoc label) {
43         this.value = value;
44         this.label = label;
45     }
46
47     /** Properties */
48
49     /**
50      * String that represents the value
51      */

52     private String JavaDoc value;
53     
54     public String JavaDoc getValue() {
55         return value;
56     }
57
58     public void setValue(String JavaDoc string) {
59         value = string;
60     }
61
62     /**
63      * Property that contains the label associated to the allowable value
64      */

65     private String JavaDoc label;
66
67     public String JavaDoc getLabel() {
68         return label;
69     }
70
71     public void setLabel(String JavaDoc string) {
72         label = string;
73     }
74     
75     /**
76      * Indicates whether some AllowableValue object is equals to this one
77      * @param obj Object that must be an instance of AllowableValue
78      * @return true if this object is the same as the obj argument; false otherwise.
79      * @exception IllegalArgumentException Thown if the object is not of type AllowableValue
80      * @see java.lang.Object#equals(java.lang.Object)
81      */

82     public boolean equals(Object JavaDoc obj) {
83         if (!(obj instanceof AllowableValue)) {
84             throw new IllegalArgumentException JavaDoc("The object to be compared is of the wrong type");
85         }
86
87         AllowableValue allObj = (AllowableValue) obj;
88         return this.getValue().equals(allObj.getValue());
89     }
90 }
91
Popular Tags