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: /**
20: * A unique user Id which is generated by the application.
21: *
22: * @author rkirkend
23: */
24: public final class WorkflowUserId implements UserId {
25:
26: private static final long serialVersionUID = -5551723348738932404L;
27:
28: private String workflowId;
29:
30: public WorkflowUserId(String workflowId) {
31: setWorkflowId(workflowId);
32: }
33:
34: public WorkflowUserId() {
35: }
36:
37: public String getId() {
38: return getWorkflowId();
39: }
40:
41: public String getWorkflowId() {
42: return workflowId;
43: }
44:
45: public void setWorkflowId(String workflowId) {
46: this .workflowId = (workflowId == null ? null : workflowId
47: .trim());
48: }
49:
50: /**
51: * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things.
52: *
53: * @return true if this instance doesn't have a value
54: */
55: public boolean isEmpty() {
56: return (workflowId == null || workflowId.trim().length() == 0);
57: }
58:
59: /**
60: * If you make this class non-final, you must rewrite equals to work for subclasses.
61: */
62: public boolean equals(Object obj) {
63: if (obj != null && (obj instanceof WorkflowUserId)) {
64: WorkflowUserId w = (WorkflowUserId) obj;
65:
66: if (getWorkflowId() == null) {
67: return false;
68: }
69: return workflowId.equals(w.getWorkflowId());
70: }
71:
72: return false;
73: }
74:
75: public int hashCode() {
76: return workflowId == null ? 0 : workflowId.hashCode();
77: }
78:
79: public String toString() {
80: if (workflowId == null) {
81: return "workflowId: null";
82: }
83: return "workflowId: " + workflowId;
84: }
85: }
|