KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > net > sf > anupam > csv > beans > Designation


1 /*
2  * Designation.java
3  *
4  * Copyright (C) 2005 Anupam Sengupta (anupamsg@users.sourceforge.net)
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  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * Version: $Revision: 1.2 $
21  */

22 package test.net.sf.anupam.csv.beans;
23
24 import org.apache.commons.lang.builder.CompareToBuilder;
25 import org.apache.commons.lang.builder.EqualsBuilder;
26 import org.apache.commons.lang.builder.HashCodeBuilder;
27 import org.apache.commons.lang.builder.ToStringBuilder;
28
29 /**
30  * Sample bean to represent an employee designation.
31  *
32  * @author Anupam Sengupta
33  * @version $Revision: 1.2 $
34  * @csv.bean-mapping bean-name="designationBean" csv-header="true"
35  */

36 public class Designation
37         implements Comparable JavaDoc<Designation> {
38
39     /**
40      * The designation.
41      */

42     private String JavaDoc designation;
43
44     /**
45      * Constructor for Designation.
46      */

47     public Designation() {
48         super();
49     }
50
51     /**
52      * Compares this designation to another designation.
53      *
54      * @param other the other designation to compare against
55      * @return <code>0</code> if the two designations are equal, <code>-1</code> if this
56      * designation ranks lower, <code>+1</code> if this designation ranks higher
57      * @see Comparable#compareTo(Object)
58      */

59     public int compareTo(final Designation other) {
60
61         return new CompareToBuilder().append(designation, other.designation)
62                 .toComparison();
63     }
64
65     /**
66      * Returns the string representation of this designation for <strong>debugging</strong>
67      * purposes only.
68      *
69      * @return the string representation
70      * @see Object#toString()
71      */

72     @Override JavaDoc
73     public String JavaDoc toString() {
74         return new ToStringBuilder(this).append("designation", designation)
75                 .toString();
76     }
77
78     /**
79      * Returns the hash code for this designation. The hash code is based on the designation string.
80      *
81      * @return the hash code for this designation
82      * @see Object#hashCode()
83      */

84     @Override JavaDoc
85     public int hashCode() {
86         return new HashCodeBuilder().append(designation).toHashCode();
87     }
88
89     /**
90      * Compares this designation with another for equality. The equality is based on the
91      * designation string.
92      *
93      * @param other the other designation to compare against
94      * @return <code>true</code> if the designations are equal, <code>false</code> otherwise
95      * @see Object#equals(Object)
96      */

97     @Override JavaDoc
98     public boolean equals(final Object JavaDoc other) {
99         if (this == other) {
100             return true;
101         }
102
103         if (!(other instanceof Designation)) {
104             return false;
105         }
106         final Designation castOther = (Designation) other;
107         return new EqualsBuilder().append(designation, castOther.designation)
108                 .isEquals();
109     }
110
111     /**
112      * Returns value of the designation.
113      *
114      * @return Returns the designation.
115      * @csv.field-mapping position="4"
116      */

117     public String JavaDoc getDesignation() {
118         return this.designation;
119     }
120
121     /**
122      * Sets value of the designation.
123      *
124      * @param designation The designation to set.
125      */

126     public void setDesignation(final String JavaDoc designation) {
127         this.designation = designation;
128     }
129
130 }
131
Popular Tags