001    /*
002     * Copyright 2007-2009 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.kew.identity;
017    
018    import org.kuali.rice.kew.user.UserId;
019    
020    /**
021     * The name of a Principal in KIM
022     * 
023     * @author Kuali Rice Team (rice.collab@kuali.org)
024     *
025     */
026    public class PrincipalName implements UserId {
027    
028            private String id;
029            
030            public PrincipalName() {
031                    super();
032            }
033    
034            public PrincipalName(String principalName) {
035                    id = principalName;
036            }
037            
038            public String getPrincipalName() {
039                    return id;
040            }
041            
042            public void setPrincipalName(String principalName) {
043                    id = principalName;
044            }
045            
046            @Override
047            public String getId() {
048                    return getPrincipalName();
049            }
050    
051            @Override
052            public boolean isEmpty() {
053                    return id == null || id.trim().length() == 0;
054            }
055            
056            @Override
057            public int hashCode() {
058                    final int prime = 31;
059                    int result = 1;
060                    result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
061                    return result;
062            }
063    
064            @Override
065            public boolean equals(Object obj) {
066                    if (this == obj)
067                            return true;
068                    if (obj == null)
069                            return false;
070                    if (getClass() != obj.getClass())
071                            return false;
072                    PrincipalName other = (PrincipalName) obj;
073                    if (this.id == null) {
074                            if (other.id != null)
075                                    return false;
076                    } else if (!this.id.equals(other.id))
077                            return false;
078                    return true;
079            }
080    
081            @Override
082            public String toString() {
083                    return "PrincipalName [id=" + this.id + "]";
084            }
085    }