View Javadoc

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