View Javadoc

1   /*
2    * Copyright 2007-2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.identity;
17  
18  import org.kuali.rice.kew.user.UserId;
19  
20  /**
21   * The name of a Principal in KIM
22   * 
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   *
25   */
26  public class PrincipalName implements UserId {
27  
28  	private String id;
29  	
30  	public PrincipalName() {
31  		super();
32  	}
33  
34  	public PrincipalName(String principalName) {
35  		id = principalName;
36  	}
37  	
38  	public String getPrincipalName() {
39  		return id;
40  	}
41  	
42  	public void setPrincipalName(String principalName) {
43  		id = principalName;
44  	}
45  	
46  	@Override
47  	public String getId() {
48  		return getPrincipalName();
49  	}
50  
51  	@Override
52  	public boolean isEmpty() {
53  		return id == null || id.trim().length() == 0;
54  	}
55  	
56  	@Override
57  	public int hashCode() {
58  		final int prime = 31;
59  		int result = 1;
60  		result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
61  		return result;
62  	}
63  
64  	@Override
65  	public boolean equals(Object obj) {
66  		if (this == obj)
67  			return true;
68  		if (obj == null)
69  			return false;
70  		if (getClass() != obj.getClass())
71  			return false;
72  		PrincipalName other = (PrincipalName) obj;
73  		if (this.id == null) {
74  			if (other.id != null)
75  				return false;
76  		} else if (!this.id.equals(other.id))
77  			return false;
78  		return true;
79  	}
80  
81  	@Override
82  	public String toString() {
83  		return "PrincipalName [id=" + this.id + "]";
84  	}
85  }