1 /* 2 * Copyright (c) 2005 Regents of the University of California (Regents). Created 3 * by TELS, Graduate School of Education, University of California at Berkeley. 4 * 5 * This software is distributed under the GNU Lesser General Public License, v2. 6 * 7 * Permission is hereby granted, without written agreement and without license 8 * or royalty fees, to use, copy, modify, and distribute this software and its 9 * documentation for any purpose, provided that the above copyright notice and 10 * the following two paragraphs appear in all copies of this software. 11 * 12 * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 13 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 14 * PURPOSE. THE SOFTWAREAND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 15 * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 16 * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 17 * 18 * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 19 * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, 20 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 21 * REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 */ 23 package net.sf.sail.core.entity; 24 25 public class Role { 26 27 String roleName; 28 29 /** 30 * Role that is always defined 31 */ 32 public static final Role INDIVIDUAL = new Role("individual"); 33 34 public static final Role RUN_WORKGROUP = new Role("run workgroup"); 35 36 public Role(String string) { 37 roleName = string.intern(); 38 } 39 40 public String getRoleName() { 41 return roleName; 42 } 43 44 public void setRoleName(String roleName) { 45 this.roleName = roleName.intern(); 46 } 47 48 @Override 49 public String toString() { 50 return "Role(" + roleName + ")"; 51 } 52 53 @Override 54 public boolean equals(Object obj) { 55 if (!(obj instanceof Role)) 56 return false; 57 58 Role otherRole = (Role) obj; 59 // safe since all names are interned 60 return roleName == otherRole.roleName; 61 } 62 63 @Override 64 public int hashCode() { 65 return roleName.hashCode(); 66 } 67 68 }