View Javadoc

1   /*
2    * $Id: RoleImpl.java 124 2004-11-01 18:09:40Z josem $
3    *
4    * Tarsis
5    * Copyright (C) 2002 Talika Open Source Group
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   *
21   */
22  
23  package org.talika.tarsis.security;
24  
25  import java.io.Serializable;
26  
27  /**
28   * Implementation of <code>Role</code> interface.
29   *
30   * @author  Jose M. Palomar
31   * @version $Revision: 124 $
32   */
33  public final class RoleImpl implements Role, Serializable {
34  
35      // Fields
36      /**
37       * Name of role.
38       */
39      private final String name;
40  
41      // Constructors
42      /**
43       * Creates a new <code>RoleImpl</code>.
44       *
45       * @param name String name of role.
46       */
47      public RoleImpl(String name) {
48          this.name = name;
49      }
50  
51      // Methods
52      /**
53       * Returns name of role.
54       *
55       * @return String name of role.
56       * @see org.talika.tarsis.security.Role#getName()
57       */
58      public String getName() {
59          return name;
60      }
61  
62      /**
63       * Indicates whether some other object is "equal to" this one.
64       *
65       * @param obj Object the reference object with which to compare.
66       * @return boolean <code>true</code> if this object is the same as the obj
67       * argument; <code>false</code> otherwise.
68       */
69      public boolean equals(Object obj) {
70          return ((obj instanceof Role) && ((Role) obj).getName().equals(this.name));
71      }
72  
73      /**
74       * Returns a hash code value for the object.
75       *
76       * @return int a hash code value for this object.
77       */
78      public int hashCode() {
79          return this.name.hashCode();
80      }
81  
82      /**
83       * Returns a string representation of the object.
84       *
85       * @return String a string representation of the object.
86       */
87      public String toString() {
88          return name;
89      }
90  
91  }