| 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 | 0 | public KualiCodeBase() { |
| 42 | 0 | this.active = true; |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
public KualiCodeBase(String code) { |
| 46 | 0 | this(); |
| 47 | 0 | this.code = code; |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
public String getCode() { |
| 54 | 0 | return code; |
| 55 | |
} |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
public void setCode(String code) { |
| 61 | 0 | this.code = code; |
| 62 | 0 | } |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
public String getName() { |
| 69 | 0 | return name; |
| 70 | |
} |
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
public void setName(String name) { |
| 77 | 0 | this.name = name; |
| 78 | 0 | } |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
public boolean isActive() { |
| 85 | 0 | return active; |
| 86 | |
} |
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
public void setActive(boolean a) { |
| 93 | 0 | this.active = a; |
| 94 | 0 | } |
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
public String getCodeAndDescription() { |
| 100 | 0 | return KualiCodeBase.getCodeAndDescription(getCode(), getName()); |
| 101 | |
} |
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
public static String getCodeAndDescription(String code, String desc) { |
| 108 | 0 | if (code != null) { |
| 109 | 0 | if (desc == null) { |
| 110 | 0 | return code; |
| 111 | |
} else { |
| 112 | 0 | return code + " - " + desc; |
| 113 | |
} |
| 114 | |
} |
| 115 | 0 | return ""; |
| 116 | |
} |
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
@SuppressWarnings("unchecked") |
| 122 | |
protected LinkedHashMap toStringMapper() { |
| 123 | 0 | LinkedHashMap m = new LinkedHashMap(); |
| 124 | |
|
| 125 | 0 | m.put("code", getCode()); |
| 126 | 0 | m.put("name", getName()); |
| 127 | |
|
| 128 | 0 | return m; |
| 129 | |
} |
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
public boolean equals(Object obj) { |
| 137 | 0 | if (obj instanceof KualiCodeBase) { |
| 138 | 0 | return StringUtils.equals(this.getCode(), ((KualiCodeBase) obj).getCode()); |
| 139 | |
} |
| 140 | 0 | return false; |
| 141 | |
} |
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
public int hashCode() { |
| 149 | 0 | int hashCode = 0; |
| 150 | |
|
| 151 | 0 | if (getCode() != null) { |
| 152 | 0 | hashCode = getCode().hashCode(); |
| 153 | |
} |
| 154 | |
|
| 155 | 0 | return hashCode; |
| 156 | |
} |
| 157 | |
} |