View Javadoc

1   package com.panogenesis.model;
2   
3   import java.io.Serializable;
4   import java.util.Set;
5   
6   import org.apache.commons.lang.builder.EqualsBuilder;
7   import org.apache.commons.lang.builder.HashCodeBuilder;
8   import org.apache.commons.lang.builder.ToStringBuilder;
9   import org.apache.commons.lang.builder.ToStringStyle;
10  
11  /***
12   * This class is used to represent available roles in the database.</p>
13   *
14   * <p><a href="Role.java.html"><i>View Source</i></a></p>
15   *
16   * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
17   *  Version by Dan Kibler dan@getrolling.com
18   *
19   * @struts.form extends="BaseForm"
20   * @hibernate.class table="role"
21   */
22  public class Role extends BaseObject implements Serializable {
23      //~ Instance fields ========================================================
24  
25      private String name;
26      private String description;
27      private Integer version;
28      private Set users;
29  
30      public Role() {}
31      
32      public Role(String name) {
33          this.name = name;
34      }
35      
36      //~ Methods ================================================================
37  
38      /***
39       * Returns the name.
40       * @return String
41       *
42       * @struts.validator type="required"
43       * @hibernate.id column="name" length="20"
44       *   generator-class="assigned" unsaved-value="version"
45       */
46      public String getName() {
47          return this.name;
48      }
49  
50      /***
51       * Returns the description.
52       * @return String
53       *
54       * @struts.validator type="required"
55       * @hibernate.property column="description"
56       */
57      public String getDescription() {
58          return this.description;
59      }
60  
61      public void setName(String name) {
62          this.name = name;
63      }
64  
65      public void setDescription(String description) {
66          this.description = description;
67      }
68  
69      /***
70       * @return Returns the users.
71       * This inverse relation causes exceptions :-( drk
72       * hibernate.set table="user_role" cascade="save-update"
73       *                lazy="false" inverse="true"
74       * hibernate.collection-key column="role_name"
75       * hibernate.collection-many-to-many class="com.panogenesis.model.User"
76       *                                    column="username"
77       */
78      public Set getUsers() {
79          return users;
80      }
81      
82      /***
83       * @param users The users to set.
84       */
85      public void setUsers(Set users) {
86          this.users = users;
87      }
88  
89      /***
90       * @return Returns the version.
91       * @hibernate.version
92       */
93      public Integer getVersion() {
94          return version;
95      }
96      /***
97       * @param version The version to set.
98       */
99      public void setVersion(Integer version) {
100         this.version = version;
101     }
102 
103     /***
104      * Generated using Commonclipse (http://commonclipse.sf.net)
105      */
106     public boolean equals(Object object) {
107         if (!(object instanceof Role)) {
108             return false;
109         }
110         Role rhs = (Role) object;
111         return new EqualsBuilder().append(this.description, rhs.description)
112                 .append(this.name, rhs.name).isEquals();
113     }
114 
115     /***
116      * Generated using Commonclipse (http://commonclipse.sf.net)
117      */
118     public int hashCode() {
119         return new HashCodeBuilder(1156335803, 987569255).append(
120                 this.description).append(this.name).toHashCode();
121     }
122     
123     /***
124      * Generated using Commonclipse (http://commonclipse.sf.net)
125      */
126     public String toString() {
127         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
128                 .append("name", this.name).append("description",
129                         this.description).toString();
130     }
131 
132 }