1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.bo;
17
18 import java.util.LinkedHashMap;
19
20 import javax.persistence.Column;
21 import javax.persistence.Id;
22 import javax.persistence.MappedSuperclass;
23
24 import org.apache.commons.lang.StringUtils;
25 import org.hibernate.annotations.Type;
26
27 @MappedSuperclass
28 public class KualiCodeBase extends PersistableBusinessObjectBase implements KualiCode {
29
30 private static final long serialVersionUID = 1194744068788100482L;
31
32 @Id
33 @Column(name="CODE")
34 protected String code;
35 @Column(name="NM")
36 protected String name;
37 @Type(type="yes_no")
38 @Column(name="ACTV_IND")
39 protected boolean active;
40
41 public KualiCodeBase() {
42 this.active = true;
43 }
44
45 public KualiCodeBase(String code) {
46 this();
47 this.code = code;
48 }
49
50
51
52
53 public String getCode() {
54 return code;
55 }
56
57
58
59
60 public void setCode(String code) {
61 this.code = code;
62 }
63
64
65
66
67
68 public String getName() {
69 return name;
70 }
71
72
73
74
75
76 public void setName(String name) {
77 this.name = name;
78 }
79
80
81
82
83
84 public boolean isActive() {
85 return active;
86 }
87
88
89
90
91
92 public void setActive(boolean a) {
93 this.active = a;
94 }
95
96
97
98
99 public String getCodeAndDescription() {
100 return KualiCodeBase.getCodeAndDescription(getCode(), getName());
101 }
102
103
104
105
106
107 public static String getCodeAndDescription(String code, String desc) {
108 if (code != null) {
109 if (desc == null) {
110 return code;
111 } else {
112 return code + " - " + desc;
113 }
114 }
115 return "";
116 }
117
118
119
120
121 @SuppressWarnings("unchecked")
122 protected LinkedHashMap toStringMapper() {
123 LinkedHashMap m = new LinkedHashMap();
124
125 m.put("code", getCode());
126 m.put("name", getName());
127
128 return m;
129 }
130
131
132
133
134
135
136 public boolean equals(Object obj) {
137 if (obj instanceof KualiCodeBase) {
138 return StringUtils.equals(this.getCode(), ((KualiCodeBase) obj).getCode());
139 }
140 return false;
141 }
142
143
144
145
146
147
148 public int hashCode() {
149 int hashCode = 0;
150
151 if (getCode() != null) {
152 hashCode = getCode().hashCode();
153 }
154
155 return hashCode;
156 }
157 }