KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > appfuse > model > Role


1 package org.appfuse.model;
2
3 import java.io.Serializable JavaDoc;
4
5 import org.acegisecurity.GrantedAuthority;
6 import org.apache.commons.lang.builder.ToStringBuilder;
7 import org.apache.commons.lang.builder.ToStringStyle;
8
9 /**
10  * This class is used to represent available roles in the database.</p>
11  *
12  * <p><a HREF="Role.java.htm"><i>View Source</i></a></p>
13  *
14  * @author <a HREF="mailto:matt@raibledesigns.com">Matt Raible</a>
15  * Version by Dan Kibler dan@getrolling.com
16  * Extended to implement Acegi GrantedAuthority interface
17  * by David Carter david@carter.net
18  *
19  * @struts.form extends="BaseForm"
20  * @hibernate.class table="role"
21  */

22 public class Role extends BaseObject implements Serializable JavaDoc, GrantedAuthority {
23     private static final long serialVersionUID = 3690197650654049848L;
24     private Long JavaDoc id;
25     private String JavaDoc name;
26     private String JavaDoc description;
27
28     public Role() {}
29     
30     public Role(String JavaDoc name) {
31         this.name = name;
32     }
33     
34     /**
35      * @hibernate.id column="id" generator-class="native" unsaved-value="null"
36      */

37     public Long JavaDoc getId() {
38         return id;
39     }
40
41     /**
42      * @see org.acegisecurity.GrantedAuthority#getAuthority()
43      */

44     public String JavaDoc getAuthority() {
45         return getName();
46     }
47     
48     /**
49      * @hibernate.property column="name" length="20"
50      */

51     public String JavaDoc getName() {
52         return this.name;
53     }
54
55     /**
56      * @hibernate.property column="description" length="64"
57      */

58     public String JavaDoc getDescription() {
59         return this.description;
60     }
61     
62     public void setId(Long JavaDoc id) {
63         this.id = id;
64     }
65
66     public void setName(String JavaDoc name) {
67         this.name = name;
68     }
69
70     public void setDescription(String JavaDoc description) {
71         this.description = description;
72     }
73
74     public boolean equals(Object JavaDoc o) {
75         if (this == o) return true;
76         if (!(o instanceof Role)) return false;
77
78         final Role role = (Role) o;
79
80         return !(name != null ? !name.equals(role.name) : role.name != null);
81
82     }
83
84     public int hashCode() {
85         return (name != null ? name.hashCode() : 0);
86     }
87
88     public String JavaDoc toString() {
89         return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
90                 .append(this.name)
91                 .toString();
92     }
93
94 }
95
Popular Tags