001 /** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kew.workgroup; 017 018 /** 019 * A {@link GroupId} which is a unique numerical identifier for a {@link Workgroup}. 020 * 021 * @see Workgroup 022 * 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025 public final class WorkflowGroupId implements GroupId { 026 027 private static final long serialVersionUID = -2452096307070075024L; 028 029 private Long groupId; 030 031 public WorkflowGroupId(Long groupId) { 032 this.groupId = groupId; 033 } 034 035 public Long getGroupId() { 036 return groupId; 037 } 038 039 /** 040 * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things. 041 * 042 * @return true if this instance doesn't have a value 043 */ 044 public boolean isEmpty() { 045 return groupId == null; 046 } 047 048 /** 049 * If you make this class non-final, you must rewrite equals to work for subclasses. 050 */ 051 public boolean equals(Object obj) { 052 boolean isEqual = false; 053 054 if (obj != null && (obj instanceof WorkflowGroupId)) { 055 WorkflowGroupId w = (WorkflowGroupId) obj; 056 057 if (w.getGroupId() != null && getGroupId() != null) { 058 return w.getGroupId().equals(getGroupId()); 059 } else { 060 return false; 061 } 062 } 063 064 return isEqual; 065 } 066 067 public int hashCode() { 068 if (groupId == null) { 069 return 0; 070 } 071 return groupId.hashCode(); 072 } 073 074 public String toString() { 075 if (groupId != null) { 076 return groupId.toString(); 077 } 078 return "null"; 079 } 080 }