1 /**
2 * Copyright 2005-2012 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.kew.workgroup;
17
18 /**
19 * A {@link GroupId} which is a unique numerical identifier for a {@link Workgroup}.
20 *
21 * @see Workgroup
22 *
23 * @author Kuali Rice Team (rice.collab@kuali.org)
24 */
25 public final class WorkflowGroupId implements GroupId {
26
27 private static final long serialVersionUID = -2452096307070075024L;
28
29 private Long groupId;
30
31 public WorkflowGroupId(Long groupId) {
32 this.groupId = groupId;
33 }
34
35 public Long getGroupId() {
36 return groupId;
37 }
38
39 /**
40 * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things.
41 *
42 * @return true if this instance doesn't have a value
43 */
44 public boolean isEmpty() {
45 return groupId == null;
46 }
47
48 /**
49 * If you make this class non-final, you must rewrite equals to work for subclasses.
50 */
51 public boolean equals(Object obj) {
52 boolean isEqual = false;
53
54 if (obj != null && (obj instanceof WorkflowGroupId)) {
55 WorkflowGroupId w = (WorkflowGroupId) obj;
56
57 if (w.getGroupId() != null && getGroupId() != null) {
58 return w.getGroupId().equals(getGroupId());
59 } else {
60 return false;
61 }
62 }
63
64 return isEqual;
65 }
66
67 public int hashCode() {
68 if (groupId == null) {
69 return 0;
70 }
71 return groupId.hashCode();
72 }
73
74 public String toString() {
75 if (groupId != null) {
76 return groupId.toString();
77 }
78 return "null";
79 }
80 }