| 1 | |
package org.kuali.rice.krms.api.repository; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
import java.util.Collection; |
| 5 | |
|
| 6 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 7 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 8 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 9 | |
import javax.xml.bind.annotation.XmlElement; |
| 10 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 11 | |
import javax.xml.bind.annotation.XmlType; |
| 12 | |
|
| 13 | |
import org.apache.commons.lang.StringUtils; |
| 14 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
| 15 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
| 16 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
| 17 | |
import org.kuali.rice.core.api.CoreConstants; |
| 18 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 19 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | 0 | @XmlRootElement(name = KrmsTypeAttribute.Constants.ROOT_ELEMENT_NAME) |
| 28 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 29 | |
@XmlType(name = KrmsTypeAttribute.Constants.TYPE_NAME, propOrder = { |
| 30 | |
KrmsTypeAttribute.Elements.ID, |
| 31 | |
KrmsTypeAttribute.Elements.TYPE_ID, |
| 32 | |
KrmsTypeAttribute.Elements.ATTR_DEFN_ID, |
| 33 | |
KrmsTypeAttribute.Elements.SEQ_NO, |
| 34 | |
KrmsTypeAttribute.Elements.ACTIVE, |
| 35 | |
KrmsTypeAttribute.Elements.ATTR_DEFN, |
| 36 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 37 | |
}) |
| 38 | 0 | public final class KrmsTypeAttribute implements KrmsTypeAttributeContract, ModelObjectComplete{ |
| 39 | |
private static final long serialVersionUID = -304265575559412478L; |
| 40 | |
|
| 41 | |
@XmlElement(name = Elements.ID, required=true) |
| 42 | |
private String id; |
| 43 | |
@XmlElement(name = Elements.TYPE_ID, required=true) |
| 44 | |
private String typeId; |
| 45 | |
@XmlElement(name = Elements.ATTR_DEFN_ID, required=true) |
| 46 | |
private String attributeDefinitionId; |
| 47 | |
@XmlElement(name = Elements.SEQ_NO, required=true) |
| 48 | |
private Integer sequenceNumber; |
| 49 | |
@XmlElement(name = Elements.ACTIVE, required=false) |
| 50 | |
private boolean active; |
| 51 | |
@XmlElement(name = Elements.ATTR_DEFN, required=false) |
| 52 | |
private KrmsAttributeDefinition attributeDefinition; |
| 53 | |
|
| 54 | 0 | @SuppressWarnings("unused") |
| 55 | |
@XmlAnyElement |
| 56 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | 0 | private KrmsTypeAttribute() { |
| 62 | 0 | this.id = null; |
| 63 | 0 | this.typeId = null; |
| 64 | 0 | this.attributeDefinitionId = null; |
| 65 | 0 | this.sequenceNumber = null; |
| 66 | 0 | this.active = false; |
| 67 | 0 | this.attributeDefinition = null; |
| 68 | 0 | } |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | 0 | private KrmsTypeAttribute(Builder builder) { |
| 77 | 0 | this.id = builder.getId(); |
| 78 | 0 | this.typeId = builder.getTypeId(); |
| 79 | 0 | this.attributeDefinitionId = builder.getAttributeDefinitionId(); |
| 80 | 0 | this.sequenceNumber = builder.getSequenceNumber(); |
| 81 | 0 | this.active = builder.isActive(); |
| 82 | 0 | this.attributeDefinition = builder.getAttributeDefinition().build(); |
| 83 | 0 | } |
| 84 | |
|
| 85 | |
public String getId() { |
| 86 | 0 | return this.id; |
| 87 | |
} |
| 88 | |
|
| 89 | |
public String getTypeId() { |
| 90 | 0 | return this.typeId; |
| 91 | |
} |
| 92 | |
|
| 93 | |
public String getAttributeDefinitionId() { |
| 94 | 0 | return this.attributeDefinitionId; |
| 95 | |
} |
| 96 | |
|
| 97 | |
public Integer getSequenceNumber() { |
| 98 | 0 | return this.sequenceNumber; |
| 99 | |
} |
| 100 | |
|
| 101 | |
public boolean isActive() { |
| 102 | 0 | return this.active; |
| 103 | |
} |
| 104 | |
|
| 105 | |
public KrmsAttributeDefinition getAttributeDefinition() { |
| 106 | 0 | return this.attributeDefinition; |
| 107 | |
} |
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | 0 | public static class Builder implements KrmsTypeAttributeContract, ModelBuilder, Serializable { |
| 113 | |
private static final long serialVersionUID = 2729964674427296346L; |
| 114 | |
|
| 115 | |
private String id; |
| 116 | |
private String typeId; |
| 117 | |
private String attributeDefinitionId; |
| 118 | |
private Integer sequenceNumber; |
| 119 | |
private boolean active; |
| 120 | |
private KrmsAttributeDefinition.Builder attributeDefinition; |
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | 0 | private Builder(String id, String typeId, String attributeDefinitionId, Integer sequenceNumber) { |
| 126 | 0 | setId(id); |
| 127 | 0 | setTypeId(typeId); |
| 128 | 0 | setAttributeDefinitionId(attributeDefinitionId); |
| 129 | 0 | setSequenceNumber(sequenceNumber); |
| 130 | 0 | setActive(true); |
| 131 | 0 | } |
| 132 | |
|
| 133 | |
public Builder attributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition){ |
| 134 | 0 | setAttributeDefinition(attributeDefinition); |
| 135 | 0 | return this; |
| 136 | |
} |
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
public static Builder create(String id, String typeId, String attributeDefinitionId, Integer sequenceNumber) { |
| 149 | 0 | return new Builder(id, typeId, attributeDefinitionId, sequenceNumber); |
| 150 | |
} |
| 151 | |
|
| 152 | |
public static Builder create(KrmsTypeAttributeContract contract){ |
| 153 | 0 | if (contract == null) { |
| 154 | 0 | throw new IllegalArgumentException("contract is null"); |
| 155 | |
} |
| 156 | 0 | Builder builder = new Builder(contract.getId(), |
| 157 | |
contract.getTypeId(), |
| 158 | |
contract.getAttributeDefinitionId(), |
| 159 | |
contract.getSequenceNumber()) |
| 160 | |
.attributeDefinition(KrmsAttributeDefinition.Builder |
| 161 | |
.create(contract.getAttributeDefinition())); |
| 162 | 0 | return builder; |
| 163 | |
} |
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
public void setId(String id) { |
| 172 | 0 | if (StringUtils.isBlank(id)) { |
| 173 | 0 | throw new IllegalArgumentException("id is blank"); |
| 174 | |
} |
| 175 | 0 | this.id = id; |
| 176 | 0 | } |
| 177 | |
|
| 178 | |
public void setTypeId(String typeId) { |
| 179 | 0 | if (StringUtils.isBlank(typeId)) { |
| 180 | 0 | throw new IllegalArgumentException("typeId is blank"); |
| 181 | |
} |
| 182 | 0 | this.typeId = typeId; |
| 183 | 0 | } |
| 184 | |
|
| 185 | |
public void setAttributeDefinitionId(String attributeDefinitionId) { |
| 186 | 0 | if (StringUtils.isBlank(attributeDefinitionId)) { |
| 187 | 0 | throw new IllegalArgumentException("the attribute definition id is blank"); |
| 188 | |
} |
| 189 | 0 | this.attributeDefinitionId = attributeDefinitionId; |
| 190 | 0 | } |
| 191 | |
|
| 192 | |
public void setSequenceNumber(Integer sequenceNumber) { |
| 193 | 0 | this.sequenceNumber = sequenceNumber; |
| 194 | 0 | } |
| 195 | |
|
| 196 | |
public void setAttributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition) { |
| 197 | 0 | this.attributeDefinition = attributeDefinition; |
| 198 | |
|
| 199 | 0 | } |
| 200 | |
|
| 201 | |
public void setActive(boolean active) { |
| 202 | 0 | this.active = active; |
| 203 | 0 | } |
| 204 | |
|
| 205 | |
public String getId() { |
| 206 | 0 | return id; |
| 207 | |
} |
| 208 | |
|
| 209 | |
public String getTypeId() { |
| 210 | 0 | return typeId; |
| 211 | |
} |
| 212 | |
|
| 213 | |
public String getAttributeDefinitionId() { |
| 214 | 0 | return attributeDefinitionId; |
| 215 | |
} |
| 216 | |
|
| 217 | |
public Integer getSequenceNumber() { |
| 218 | 0 | return sequenceNumber; |
| 219 | |
} |
| 220 | |
|
| 221 | |
public KrmsAttributeDefinition.Builder getAttributeDefinition() { |
| 222 | 0 | return attributeDefinition; |
| 223 | |
} |
| 224 | |
|
| 225 | |
|
| 226 | |
public boolean isActive() { |
| 227 | 0 | return active; |
| 228 | |
} |
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
|
| 234 | |
|
| 235 | |
@Override |
| 236 | |
public KrmsTypeAttribute build() { |
| 237 | 0 | return new KrmsTypeAttribute(this); |
| 238 | |
} |
| 239 | |
|
| 240 | |
} |
| 241 | |
@Override |
| 242 | |
public int hashCode() { |
| 243 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 244 | |
} |
| 245 | |
|
| 246 | |
@Override |
| 247 | |
public boolean equals(Object obj) { |
| 248 | 0 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 249 | |
} |
| 250 | |
|
| 251 | |
@Override |
| 252 | |
public String toString() { |
| 253 | 0 | return ToStringBuilder.reflectionToString(this); |
| 254 | |
} |
| 255 | |
|
| 256 | |
|
| 257 | |
|
| 258 | |
|
| 259 | 0 | static class Constants { |
| 260 | |
final static String ROOT_ELEMENT_NAME = "KrmsTypeAttribute"; |
| 261 | |
final static String TYPE_NAME = "KrmsTypeAttributeType"; |
| 262 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = { CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
| 263 | |
} |
| 264 | |
|
| 265 | |
|
| 266 | |
|
| 267 | |
|
| 268 | |
|
| 269 | 0 | public static class Elements { |
| 270 | |
final static String ID = "id"; |
| 271 | |
final static String TYPE_ID = "typeId"; |
| 272 | |
final static String ATTR_DEFN_ID = "attributeDefinitionId"; |
| 273 | |
final static String SEQ_NO = "sequenceNumber"; |
| 274 | |
final static String ACTIVE = "active"; |
| 275 | |
final static String ATTR_DEFN = "attributeDefinition"; |
| 276 | |
} |
| 277 | |
} |