001 /*
002 * Copyright 2007-2009 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.kim.bo.reference.dto;
017
018 import javax.xml.bind.annotation.XmlTransient;
019
020 import org.apache.commons.lang.StringUtils;
021 import org.kuali.rice.kim.bo.reference.KimCode;
022 import org.kuali.rice.kns.bo.KualiCode;
023
024 /**
025 * This is a description of what this class does - jonathan don't forget to fill this in.
026 *
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 */
029 public abstract class KimCodeInfoBase implements KimCode {
030
031 private static final long serialVersionUID = 3391418027677414695L;
032
033 protected String code;
034 protected String name;
035 protected boolean active;
036 protected String displaySortCode = "";
037
038 public KimCodeInfoBase() {
039 super();
040 active = true;
041 }
042
043 public KimCodeInfoBase(KimCode kimCode) {
044 this();
045 if ( kimCode != null ) {
046 this.code = (kimCode.getCode() != null) ? kimCode.getCode() : "";
047 this.name = (kimCode.getName() != null) ? kimCode.getName() : "";
048 this.displaySortCode = "";
049 }
050 }
051
052 /**
053 * @return the code
054 */
055 @XmlTransient
056 public String getCode() {
057 return this.code;
058 }
059
060 /**
061 * @param code the code to set
062 */
063 public void setCode(String code) {
064 this.code = code;
065 }
066
067 /**
068 * @return the name
069 */
070 @XmlTransient
071 public String getName() {
072 return this.name;
073 }
074
075 /**
076 * @param name the name to set
077 */
078 public void setName(String name) {
079 this.name = name;
080 }
081
082 /**
083 * This overridden method ...
084 *
085 * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
086 */
087 @Override
088 public String toString() {
089 return getClass().getSimpleName() + ":" + getCode() + " - " + getName();
090 }
091
092 /**
093 * @see org.kuali.core.bo.KualiCode#isActive()
094 */
095 public boolean isActive() {
096 return active;
097 }
098
099 /**
100 * @see org.kuali.core.bo.KualiCode#setActive(boolean)
101 */
102 public void setActive(boolean active) {
103 this.active = active;
104 }
105
106 /**
107 * Implements equals comparing code to code.
108 *
109 * @see java.lang.Object#equals(java.lang.Object)
110 */
111 public boolean equals(Object obj) {
112 if (obj instanceof KualiCode) {
113 return StringUtils.equals(this.getCode(), ((KualiCode) obj).getCode());
114 }
115 return false;
116 }
117
118 /**
119 * Overriding equals requires writing a hashCode method.
120 *
121 * @see java.lang.Object#hashCode()
122 */
123 public int hashCode() {
124 int hashCode = 0;
125
126 if (getCode() != null) {
127 hashCode = getCode().hashCode();
128 }
129
130 return hashCode;
131 }
132
133 /**
134 * @return the displaySortCode
135 */
136 public String getDisplaySortCode() {
137 return this.displaySortCode;
138 }
139
140 /**
141 * @param displaySortCode the displaySortCode to set
142 */
143 public void setDisplaySortCode(String displaySortCode) {
144 this.displaySortCode = displaySortCode;
145 }
146
147 /**
148 * This overridden method ...
149 *
150 * @see org.kuali.rice.kns.bo.BusinessObject#prepareForWorkflow()
151 */
152 public void prepareForWorkflow() {}
153 public void refresh() {}
154 }