KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > pojos > RoleData


1
2 package org.roller.pojos;
3
4
5 /**
6  * Role bean.
7  * @author David M Johnson
8  *
9  * @ejb:bean name="RoleData"
10  * @struts.form include-all="true"
11  * @hibernate.class table="userrole"
12  * hibernate.jcs-cache usage="read-write"
13  */

14 public class RoleData
15    extends org.roller.pojos.PersistentObject
16    implements java.io.Serializable JavaDoc
17 {
18    static final long serialVersionUID = -4254083071697970972L;
19
20    protected java.lang.String JavaDoc id;
21    protected java.lang.String JavaDoc userName;
22    protected UserData user;
23    protected java.lang.String JavaDoc role;
24
25    public RoleData()
26    {
27    }
28
29    public RoleData(String JavaDoc id, UserData user, String JavaDoc role)
30    {
31       this.id = id;
32       this.userName = user.getUserName();
33       this.user = user;
34       this.role = role;
35    }
36
37    public RoleData( RoleData otherData )
38    {
39       this.id = otherData.id;
40       this.userName = otherData.userName;
41       this.user = otherData.user;
42       this.role = otherData.role;
43
44    }
45
46    /**
47     * @ejb:pk-field
48     * @ejb:persistent-field
49     * @hibernate.id column="id" type="string"
50     * generator-class="uuid.hex" unsaved-value="null"
51     */

52    public java.lang.String JavaDoc getId()
53    {
54       return this.id;
55    }
56    /** @ejb:persistent-field */
57    public void setId( java.lang.String JavaDoc id )
58    {
59       this.id = id;
60    }
61
62    /**
63     * @ejb:persistent-field
64     * @hibernate.property column="username" non-null="true" unique="false"
65     */

66    public java.lang.String JavaDoc getUserName()
67    {
68       return this.userName;
69    }
70    /** @ejb:persistent-field */
71    public void setUserName( java.lang.String JavaDoc userName )
72    {
73       this.userName = userName;
74    }
75
76    /**
77     * @hibernate.many-to-one column="userid" cascade="none" not-null="true"
78     * @ejb:persistent-field
79     */

80    public UserData getUser()
81    {
82       return this.user;
83    }
84    /** @ejb:persistent-field */
85    public void setUser( UserData user )
86    {
87       this.user = user;
88    }
89
90    /**
91     * @ejb:persistent-field
92     * @hibernate.property column="rolename" non-null="true" unique="false"
93     */

94    public java.lang.String JavaDoc getRole()
95    {
96       return this.role;
97    }
98    /** @ejb:persistent-field */
99    public void setRole( java.lang.String JavaDoc role )
100    {
101       this.role = role;
102    }
103
104    public String JavaDoc toString()
105    {
106       StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
107
108       str.append("id=" + id + " " + "userName=" + userName + " " + "user=" + user + " " + "role=" + role);
109       str.append('}');
110
111       return(str.toString());
112    }
113
114    public boolean equals( Object JavaDoc pOther )
115    {
116       if( pOther instanceof RoleData )
117       {
118          RoleData lTest = (RoleData) pOther;
119          boolean lEquals = true;
120
121          if( this.id == null )
122          {
123             lEquals = lEquals && ( lTest.id == null );
124          }
125          else
126          {
127             lEquals = lEquals && this.id.equals( lTest.id );
128          }
129          if( this.userName == null )
130          {
131             lEquals = lEquals && ( lTest.userName == null );
132          }
133          else
134          {
135             lEquals = lEquals && this.userName.equals( lTest.userName );
136          }
137          if( this.user == null )
138          {
139             lEquals = lEquals && ( lTest.user == null );
140          }
141          else
142          {
143             lEquals = lEquals && this.user.equals( lTest.user );
144          }
145          if( this.role == null )
146          {
147             lEquals = lEquals && ( lTest.role == null );
148          }
149          else
150          {
151             lEquals = lEquals && this.role.equals( lTest.role );
152          }
153
154          return lEquals;
155       }
156       else
157       {
158          return false;
159       }
160    }
161
162    public int hashCode()
163    {
164       int result = 17;
165       result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);
166       result = 37*result + ((this.userName != null) ? this.userName.hashCode() : 0);
167       result = 37*result + ((this.user != null) ? this.user.hashCode() : 0);
168       result = 37*result + ((this.role != null) ? this.role.hashCode() : 0);
169       return result;
170       }
171
172    /**
173     * Setter is needed in RollerImpl.storePersistentObject()
174     */

175    public void setData( org.roller.pojos.PersistentObject otherData )
176    {
177
178       this.id = ((RoleData)otherData).id;
179
180       this.userName = ((RoleData)otherData).userName;
181
182       this.user = ((RoleData)otherData).user;
183
184       this.role = ((RoleData)otherData).role;
185    }
186
187 }
188
Popular Tags