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", nullable = false)
030    private String documentTypeId;
031
032    @Column(name="CAT_NM", nullable = false)
033    private String categoryName;
034
035    /**
036     * Get the document type id
037     * @return the document type id
038     */
039    public String getDocumentTypeId() { return documentTypeId; }
040
041    /**
042     * Set the document type id
043     * @param documentTypeId the document type id to set
044     */
045    public void setDocumentTypeId(String documentTypeId) { this.documentTypeId = documentTypeId; }
046
047    /**
048     * Get the category name
049     * @return the category name
050     */
051    public String getCategoryName() { return categoryName; }
052
053    /**
054     * Set the category name
055     * @param categoryName the category name to set
056     */
057    public void setCategoryName(String categoryName) { this.categoryName = categoryName; }
058
059        /**
060         * calculates a hashcode based on the documentTypeId and categoryName
061         *
062         * @see Object#hashCode()
063         */
064        @Override
065        public int hashCode() {
066                final int prime = 31;
067                int result = 1;
068                result = prime
069                                * result
070                                + ((this.documentTypeId == null) ? 0 : this.documentTypeId
071                                                .hashCode());
072                result = prime * result
073                                + ((this.categoryName == null) ? 0 : this.categoryName.hashCode());
074                return result;
075        }
076
077        /**
078         * determines equality based on the class, documentTypeId and categoryName
079         *
080         * @see Object#equals(Object)
081         */
082        @Override
083        public boolean equals(Object obj) {
084                if (this == obj)
085                        return true;
086                if (obj == null)
087                        return false;
088                if (getClass() != obj.getClass())
089                        return false;
090                final ApplicationDocumentStatusCategoryId other = (ApplicationDocumentStatusCategoryId) obj;
091                if (this.documentTypeId == null) {
092                        if (other.documentTypeId != null)
093                                return false;
094                } else if (!this.documentTypeId.equals(other.documentTypeId))
095                        return false;
096                if (this.categoryName == null) {
097                        if (other.categoryName != null)
098                                return false;
099                } else if (!this.categoryName.equals(other.categoryName))
100                        return false;
101                return true;
102        }
103
104}
105