01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.user;
18:
19: import java.io.Serializable;
20:
21: /**
22: * UuId is a "universal" id that can be used as a foreign key into another,
23: * institutional, identity system. The workflow engine does not depend upon the
24: * existence of this Id on a {@link WorkflowUser}.
25: *
26: * @author bmcgough
27: */
28: public final class UuId implements UserId, Serializable {
29:
30: private static final long serialVersionUID = 5408293075182063097L;
31:
32: private String uuId;
33:
34: public UuId(String uuId) {
35: setUuId(uuId);
36: }
37:
38: public UuId() {
39: }
40:
41: public String getId() {
42: return getUuId();
43: }
44:
45: public String getUuId() {
46: return uuId;
47: }
48:
49: public void setUuId(String uuId) {
50: this .uuId = (uuId == null ? null : uuId.trim());
51: }
52:
53: /**
54: * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things.
55: *
56: * @return true if this instance doesn't have a value
57: */
58: public boolean isEmpty() {
59: return (uuId == null || uuId.trim().length() == 0);
60: }
61:
62: /**
63: * If you make this class non-final, you must rewrite equals to work for subclasses.
64: */
65: public boolean equals(Object obj) {
66:
67: if (obj != null && (obj instanceof UuId)) {
68: UuId a = (UuId) obj;
69:
70: if (getUuId() == null) {
71: return false;
72: }
73:
74: return uuId.equals(a.uuId);
75: }
76:
77: return false;
78: }
79:
80: public int hashCode() {
81: return uuId == null ? 0 : uuId.hashCode();
82: }
83:
84: public String toString() {
85: if (uuId == null) {
86: return "uuId: null";
87: }
88: return "uuId: " + uuId;
89: }
90: }
|