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