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