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.workgroup;
18:
19: /**
20: * A {@link GroupId} which identifies the name of a {@link Workgroup}.
21: *
22: * @see Workgroup
23: *
24: * @author rkirkend
25: */
26: public final class GroupNameId implements GroupId {
27:
28: private static final long serialVersionUID = -4625193242111678434L;
29:
30: private String nameId;
31:
32: public GroupNameId(String nameId) {
33: this .nameId = nameId;
34: }
35:
36: public String getNameId() {
37: return nameId;
38: }
39:
40: public boolean isEmpty() {
41: return (nameId == null) || (nameId.trim().length() == 0);
42: }
43:
44: /**
45: * If you make this class non-final, you must rewrite equals to work for subclasses.
46: */
47: public boolean equals(Object obj) {
48: boolean isEqual = false;
49:
50: if (obj != null && (obj instanceof GroupNameId)) {
51: GroupNameId w = (GroupNameId) obj;
52:
53: if (w.getNameId() != null && getNameId() != null) {
54: return w.getNameId().equals(getNameId());
55: } else {
56: return false;
57: }
58: }
59:
60: return isEqual;
61: }
62:
63: public int hashCode() {
64: if (nameId == null) {
65: return 0;
66: }
67: return nameId.hashCode();
68: }
69:
70: public String toString() {
71: if (nameId != null) {
72: return nameId;
73: }
74: return "null";
75: }
76:
77: }
|