001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.kew.doctype; 017 018import javax.persistence.Column; 019import javax.persistence.Embeddable; 020import java.io.Serializable; 021 022/** 023 * Composite identifier object for an {@link org.kuali.rice.kew.doctype.ApplicationDocumentStatusCategory}. The 024 * elements that uniquely identify a category are the document type id and the category name. 025 */ 026@Embeddable 027public class ApplicationDocumentStatusCategoryId implements Serializable { 028 029 @Column(name="DOC_TYP_ID") 030 private String documentTypeId; 031 @Column(name="NM") 032 private String categoryName; 033 034 /** 035 * Get the document type id 036 * @return the document type id 037 */ 038 public String getDocumentTypeId() { return documentTypeId; } 039 040 /** 041 * Set the document type id 042 * @param documentTypeId the document type id to set 043 */ 044 public void setDocumentTypeId(String documentTypeId) { this.documentTypeId = documentTypeId; } 045 046 /** 047 * Get the category name 048 * @return the category name 049 */ 050 public String getCategoryName() { return categoryName; } 051 052 /** 053 * Set the category name 054 * @param categoryName the category name to set 055 */ 056 public void setCategoryName(String categoryName) { this.categoryName = categoryName; } 057 058 /** 059 * calculates a hashcode based on the documentTypeId and categoryName 060 * 061 * @see Object#hashCode() 062 */ 063 @Override 064 public int hashCode() { 065 final int prime = 31; 066 int result = 1; 067 result = prime 068 * result 069 + ((this.documentTypeId == null) ? 0 : this.documentTypeId 070 .hashCode()); 071 result = prime * result 072 + ((this.categoryName == null) ? 0 : this.categoryName.hashCode()); 073 return result; 074 } 075 076 /** 077 * determines equality based on the class, documentTypeId and categoryName 078 * 079 * @see Object#equals(Object) 080 */ 081 @Override 082 public boolean equals(Object obj) { 083 if (this == obj) 084 return true; 085 if (obj == null) 086 return false; 087 if (getClass() != obj.getClass()) 088 return false; 089 final ApplicationDocumentStatusCategoryId other = (ApplicationDocumentStatusCategoryId) obj; 090 if (this.documentTypeId == null) { 091 if (other.documentTypeId != null) 092 return false; 093 } else if (!this.documentTypeId.equals(other.documentTypeId)) 094 return false; 095 if (this.categoryName == null) { 096 if (other.categoryName != null) 097 return false; 098 } else if (!this.categoryName.equals(other.categoryName)) 099 return false; 100 return true; 101 } 102 103} 104