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: /**
019: * This class wraps a social security number.
020: *
021: *
022: */
023: public class PersonTaxId implements UserId {
024:
025: public static final PersonTaxId NOT_FOUND = new PersonTaxId(
026: "not found");
027:
028: private String taxId;
029:
030: /**
031: * Empty constructor, available to support standard bean activity
032: */
033: public PersonTaxId() {
034: }
035:
036: /**
037: * Constructor that takes in a string taxId
038: *
039: * @param taxId
040: */
041: public PersonTaxId(String socialSecurityNumber) {
042: this ();
043: setTaxId(socialSecurityNumber);
044: }
045:
046: /**
047: * getter which returns the string taxId
048: *
049: * @return taxId
050: */
051: public String getTaxId() {
052: return taxId;
053: }
054:
055: /**
056: * setter which takes the string taxId
057: *
058: * @param taxId
059: */
060: public void setTaxId(String socialSecurityNumber) {
061: this .taxId = (socialSecurityNumber == null ? null
062: : socialSecurityNumber.trim());
063: }
064:
065: /**
066: * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things.
067: *
068: * @return true if this instance doesn't have a value
069: */
070: public boolean isEmpty() {
071: return (taxId == null || taxId.trim().length() == 0);
072: }
073:
074: /**
075: * override equals so that we can compare socialSecurityNumbers If you make this class non-final, you must rewrite equals to
076: * work for subclasses.
077: */
078: public boolean equals(Object obj) {
079: boolean isEqual = false;
080:
081: if (obj != null && (obj instanceof PersonTaxId)) {
082: PersonTaxId a = (PersonTaxId) obj;
083:
084: if (getTaxId() == null) {
085: return false;
086: }
087:
088: return taxId.equals(a.taxId);
089: }
090:
091: return false;
092: }
093:
094: /**
095: * override hashCode because we overrode equals
096: */
097: public int hashCode() {
098: return taxId == null ? 0 : taxId.hashCode();
099: }
100:
101: /**
102: * override toString so that it prints out the taxId String
103: */
104: public String toString() {
105: return taxId;
106: }
107: }
|