001/**
002 * Copyright 2005-2014 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 */
016package org.kuali.rice.kew.api.identity;
017
018import org.kuali.rice.kew.api.user.UserId;
019
020/**
021 * The Employee ID of a Person in KIM
022 * 
023 * @author Kuali Rice Team (rice.collab@kuali.org)
024 *
025 */
026public class EmployeeId implements UserId {
027    private static final long serialVersionUID = -1335314734556834644L;
028    private String employeeId;
029
030        public EmployeeId() {
031        }
032
033        public EmployeeId(String employeeId) {
034                setEmployeeId(employeeId);
035        }
036        
037        public String getEmployeeId() {
038                return this.employeeId;
039        }
040        
041        public void setEmployeeId(String employeeId) {
042                this.employeeId = (employeeId == null ? null : employeeId.trim());
043        }
044
045    @Override
046    public String getId() {
047        return getEmployeeId();
048    }
049
050    /**
051     * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things.
052     *
053     * @return true if this instance doesn't have a value
054     */
055    @Override
056    public boolean isEmpty() {
057        return (employeeId == null || employeeId.trim().length() == 0);
058    }
059
060    /**
061     * If you make this class non-final, you must rewrite equals to work for subclasses.
062     */
063    public boolean equals(Object obj) {
064
065        if (obj != null && (obj instanceof EmployeeId)) {
066            EmployeeId a = (EmployeeId) obj;
067
068            if (getEmployeeId() == null) {
069                return false;
070            }
071
072            return employeeId.equals(a.getEmployeeId());
073        }
074
075        return false;
076    }
077
078    public int hashCode() {
079        return employeeId == null ? 0 : employeeId.hashCode();
080    }
081
082    public String toString() {
083        if (employeeId == null) {
084            return "employeeId: null";
085        }
086        return "employeeId: " + employeeId;
087    }
088
089}