001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.core.bo.user;
017:
018: import java.io.Serializable;
019:
020: /**
021: * This class is a wrapper class that wraps a string payrollId to provide strong typing of this object as it can be used to find a user
022: * distinctly within our system
023: *
024: *
025: */
026: public final class PersonPayrollId implements UserId, Serializable {
027:
028: private static final long serialVersionUID = -8246941078425120732L;
029:
030: public static final PersonPayrollId NOT_FOUND = new PersonPayrollId(
031: "not found");
032:
033: private String payrollId;
034:
035: /**
036: * Constructor which takes a string emplid
037: *
038: * @param payrollId
039: */
040: public PersonPayrollId(String emplId) {
041: setPayrollId(emplId);
042: }
043:
044: /**
045: * Empty Constructor
046: *
047: */
048: public PersonPayrollId() {
049: }
050:
051: /**
052: * simple getter for the string emplid
053: *
054: * @return
055: */
056: public String getPayrollId() {
057: return payrollId;
058: }
059:
060: /**
061: * simple setter for the string emplid
062: *
063: * @param payrollId
064: */
065: public void setPayrollId(String emplId) {
066: this .payrollId = (emplId == null ? null : emplId.trim());
067: }
068:
069: /**
070: * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things.
071: *
072: * @return true if this instance doesn't have a value
073: */
074: public boolean isEmpty() {
075: return (payrollId == null || payrollId.trim().length() == 0);
076: }
077:
078: /**
079: * override equals to allow for comparison of Emplid objects If you make this class non-final, you must rewrite equals to work
080: * for subclasses.
081: */
082: public boolean equals(Object obj) {
083: boolean isEqual = false;
084:
085: if (obj != null && (obj instanceof PersonPayrollId)) {
086: PersonPayrollId a = (PersonPayrollId) obj;
087:
088: if (getPayrollId() == null) {
089: return false;
090: }
091:
092: return payrollId.equals(a.payrollId);
093: }
094:
095: return false;
096: }
097:
098: /**
099: * override of hashCode since we overrode equals
100: */
101: public int hashCode() {
102: return payrollId == null ? 0 : payrollId.hashCode();
103: }
104:
105: /**
106: * override of toString so that we print out the emplid string
107: */
108: public String toString() {
109: return payrollId;
110: }
111: }
|