| 1 | |
package org.kuali.rice.kim.api.identity.citizenship; |
| 2 | |
|
| 3 | |
import org.apache.commons.lang.StringUtils; |
| 4 | |
import org.joda.time.DateTime; |
| 5 | |
import org.kuali.rice.core.api.CoreConstants; |
| 6 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 7 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 8 | |
import org.kuali.rice.core.api.util.jaxb.DateTimeAdapter; |
| 9 | |
import org.kuali.rice.kim.api.identity.Type; |
| 10 | |
import org.w3c.dom.Element; |
| 11 | |
|
| 12 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 13 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 14 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 15 | |
import javax.xml.bind.annotation.XmlElement; |
| 16 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 17 | |
import javax.xml.bind.annotation.XmlType; |
| 18 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
| 19 | |
import java.io.Serializable; |
| 20 | |
import java.util.Collection; |
| 21 | |
|
| 22 | 11 | @XmlRootElement(name = EntityCitizenship.Constants.ROOT_ELEMENT_NAME) |
| 23 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 24 | |
@XmlType(name = EntityCitizenship.Constants.TYPE_NAME, propOrder = { |
| 25 | |
EntityCitizenship.Elements.ID, |
| 26 | |
EntityCitizenship.Elements.ENTITY_ID, |
| 27 | |
EntityCitizenship.Elements.STATUS, |
| 28 | |
EntityCitizenship.Elements.COUNTRY_CODE, |
| 29 | |
EntityCitizenship.Elements.START_DATE, |
| 30 | |
EntityCitizenship.Elements.END_DATE, |
| 31 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
| 32 | |
CoreConstants.CommonElements.OBJECT_ID, |
| 33 | |
EntityCitizenship.Elements.ACTIVE, |
| 34 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 35 | |
}) |
| 36 | 6 | public final class EntityCitizenship extends AbstractDataTransferObject |
| 37 | |
implements EntityCitizenshipContract |
| 38 | |
{ |
| 39 | |
@XmlElement(name = Elements.ID, required = false) |
| 40 | |
private final String id; |
| 41 | |
@XmlElement(name = Elements.ENTITY_ID, required = false) |
| 42 | |
private final String entityId; |
| 43 | |
@XmlElement(name = Elements.STATUS, required = false) |
| 44 | |
private final Type status; |
| 45 | |
@XmlElement(name = Elements.COUNTRY_CODE, required = false) |
| 46 | |
private final String countryCode; |
| 47 | |
@XmlJavaTypeAdapter(DateTimeAdapter.class) |
| 48 | |
@XmlElement(name = Elements.START_DATE, required = false) |
| 49 | |
private final DateTime startDate; |
| 50 | |
@XmlJavaTypeAdapter(DateTimeAdapter.class) |
| 51 | |
@XmlElement(name = Elements.END_DATE, required = false) |
| 52 | |
private final DateTime endDate; |
| 53 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
| 54 | |
private final Long versionNumber; |
| 55 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
| 56 | |
private final String objectId; |
| 57 | |
@XmlElement(name = Elements.ACTIVE, required = false) |
| 58 | |
private final boolean active; |
| 59 | 10 | @SuppressWarnings("unused") |
| 60 | |
@XmlAnyElement |
| 61 | |
private final Collection<Element> _futureElements = null; |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | 4 | private EntityCitizenship() { |
| 68 | 4 | this.status = null; |
| 69 | 4 | this.countryCode = null; |
| 70 | 4 | this.startDate = null; |
| 71 | 4 | this.endDate = null; |
| 72 | 4 | this.versionNumber = null; |
| 73 | 4 | this.objectId = null; |
| 74 | 4 | this.active = false; |
| 75 | 4 | this.id = null; |
| 76 | 4 | this.entityId = null; |
| 77 | 4 | } |
| 78 | |
|
| 79 | 6 | private EntityCitizenship(Builder builder) { |
| 80 | 6 | this.status = builder.getStatus() != null ? builder.getStatus().build() : null; |
| 81 | 6 | this.countryCode = builder.getCountryCode(); |
| 82 | 6 | this.startDate = builder.getStartDate(); |
| 83 | 6 | this.endDate = builder.getEndDate(); |
| 84 | 6 | this.versionNumber = builder.getVersionNumber(); |
| 85 | 6 | this.objectId = builder.getObjectId(); |
| 86 | 6 | this.active = builder.isActive(); |
| 87 | 6 | this.id = builder.getId(); |
| 88 | 6 | this.entityId = builder.getEntityId(); |
| 89 | 6 | } |
| 90 | |
|
| 91 | |
@Override |
| 92 | |
public String getEntityId() { |
| 93 | 4 | return this.entityId; |
| 94 | |
} |
| 95 | |
|
| 96 | |
@Override |
| 97 | |
public Type getStatus() { |
| 98 | 11 | return this.status; |
| 99 | |
} |
| 100 | |
|
| 101 | |
@Override |
| 102 | |
public String getCountryCode() { |
| 103 | 4 | return this.countryCode; |
| 104 | |
} |
| 105 | |
|
| 106 | |
@Override |
| 107 | |
public DateTime getStartDate() { |
| 108 | 4 | return this.startDate; |
| 109 | |
} |
| 110 | |
|
| 111 | |
@Override |
| 112 | |
public DateTime getEndDate() { |
| 113 | 4 | return this.endDate; |
| 114 | |
} |
| 115 | |
|
| 116 | |
@Override |
| 117 | |
public Long getVersionNumber() { |
| 118 | 4 | return this.versionNumber; |
| 119 | |
} |
| 120 | |
|
| 121 | |
@Override |
| 122 | |
public String getObjectId() { |
| 123 | 4 | return this.objectId; |
| 124 | |
} |
| 125 | |
|
| 126 | |
@Override |
| 127 | |
public boolean isActive() { |
| 128 | 4 | return this.active; |
| 129 | |
} |
| 130 | |
|
| 131 | |
@Override |
| 132 | |
public String getId() { |
| 133 | 4 | return this.id; |
| 134 | |
} |
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | 4 | public final static class Builder |
| 141 | |
implements Serializable, ModelBuilder, EntityCitizenshipContract |
| 142 | |
{ |
| 143 | |
private String entityId; |
| 144 | |
private Type.Builder status; |
| 145 | |
private String countryCode; |
| 146 | |
private DateTime startDate; |
| 147 | |
private DateTime endDate; |
| 148 | |
private Long versionNumber; |
| 149 | |
private String objectId; |
| 150 | |
private boolean active; |
| 151 | |
private String id; |
| 152 | |
|
| 153 | 8 | private Builder() { |
| 154 | 8 | } |
| 155 | |
|
| 156 | |
public static Builder create() { |
| 157 | 8 | return new Builder(); |
| 158 | |
} |
| 159 | |
|
| 160 | |
public static Builder create(EntityCitizenshipContract contract) { |
| 161 | 5 | if (contract == null) { |
| 162 | 0 | throw new IllegalArgumentException("contract was null"); |
| 163 | |
} |
| 164 | 5 | Builder builder = create(); |
| 165 | 5 | builder.setEntityId(contract.getEntityId()); |
| 166 | 5 | if (contract.getStatus() != null) { |
| 167 | 4 | builder.setStatus(Type.Builder.create(contract.getStatus())); |
| 168 | |
} |
| 169 | 5 | builder.setCountryCode(contract.getCountryCode()); |
| 170 | 5 | builder.setStartDate(contract.getStartDate()); |
| 171 | 5 | builder.setEndDate(contract.getEndDate()); |
| 172 | 5 | builder.setVersionNumber(contract.getVersionNumber()); |
| 173 | 5 | builder.setObjectId(contract.getObjectId()); |
| 174 | 5 | builder.setActive(contract.isActive()); |
| 175 | 5 | builder.setId(contract.getId()); |
| 176 | 5 | return builder; |
| 177 | |
} |
| 178 | |
|
| 179 | |
public EntityCitizenship build() { |
| 180 | 6 | return new EntityCitizenship(this); |
| 181 | |
} |
| 182 | |
|
| 183 | |
@Override |
| 184 | |
public String getEntityId() { |
| 185 | 6 | return this.entityId; |
| 186 | |
} |
| 187 | |
|
| 188 | |
@Override |
| 189 | |
public Type.Builder getStatus() { |
| 190 | 10 | return this.status; |
| 191 | |
} |
| 192 | |
|
| 193 | |
@Override |
| 194 | |
public String getCountryCode() { |
| 195 | 6 | return this.countryCode; |
| 196 | |
} |
| 197 | |
|
| 198 | |
@Override |
| 199 | |
public DateTime getStartDate() { |
| 200 | 6 | return this.startDate; |
| 201 | |
} |
| 202 | |
|
| 203 | |
@Override |
| 204 | |
public DateTime getEndDate() { |
| 205 | 6 | return this.endDate; |
| 206 | |
} |
| 207 | |
|
| 208 | |
@Override |
| 209 | |
public Long getVersionNumber() { |
| 210 | 6 | return this.versionNumber; |
| 211 | |
} |
| 212 | |
|
| 213 | |
@Override |
| 214 | |
public String getObjectId() { |
| 215 | 6 | return this.objectId; |
| 216 | |
} |
| 217 | |
|
| 218 | |
@Override |
| 219 | |
public boolean isActive() { |
| 220 | 6 | return this.active; |
| 221 | |
} |
| 222 | |
|
| 223 | |
@Override |
| 224 | |
public String getId() { |
| 225 | 6 | return this.id; |
| 226 | |
} |
| 227 | |
|
| 228 | |
public void setEntityId(String entityId) { |
| 229 | 5 | this.entityId = entityId; |
| 230 | 5 | } |
| 231 | |
public void setStatus(Type.Builder status) { |
| 232 | 4 | this.status = status; |
| 233 | 4 | } |
| 234 | |
|
| 235 | |
public void setCountryCode(String countryCode) { |
| 236 | 5 | this.countryCode = countryCode; |
| 237 | 5 | } |
| 238 | |
|
| 239 | |
public void setStartDate(DateTime startDate) { |
| 240 | 5 | this.startDate = startDate; |
| 241 | 5 | } |
| 242 | |
|
| 243 | |
public void setEndDate(DateTime endDate) { |
| 244 | 5 | this.endDate = endDate; |
| 245 | 5 | } |
| 246 | |
|
| 247 | |
public void setVersionNumber(Long versionNumber) { |
| 248 | 5 | this.versionNumber = versionNumber; |
| 249 | 5 | } |
| 250 | |
|
| 251 | |
public void setObjectId(String objectId) { |
| 252 | 5 | this.objectId = objectId; |
| 253 | 5 | } |
| 254 | |
|
| 255 | |
public void setActive(boolean active) { |
| 256 | 5 | this.active = active; |
| 257 | 5 | } |
| 258 | |
|
| 259 | |
public void setId(String id) { |
| 260 | 6 | if (StringUtils.isWhitespace(id)) { |
| 261 | 1 | throw new IllegalArgumentException("id is blank"); |
| 262 | |
} |
| 263 | 5 | this.id = id; |
| 264 | 5 | } |
| 265 | |
|
| 266 | |
} |
| 267 | |
|
| 268 | |
|
| 269 | |
|
| 270 | |
|
| 271 | |
|
| 272 | |
|
| 273 | 0 | static class Constants { |
| 274 | |
|
| 275 | |
final static String ROOT_ELEMENT_NAME = "entityCitizenship"; |
| 276 | |
final static String TYPE_NAME = "EntityCitizenshipType"; |
| 277 | |
} |
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | |
|
| 282 | |
|
| 283 | |
|
| 284 | 0 | static class Elements { |
| 285 | |
final static String ENTITY_ID = "entityId"; |
| 286 | |
final static String STATUS = "status"; |
| 287 | |
final static String COUNTRY_CODE = "countryCode"; |
| 288 | |
final static String START_DATE = "startDate"; |
| 289 | |
final static String END_DATE = "endDate"; |
| 290 | |
final static String ACTIVE = "active"; |
| 291 | |
final static String ID = "id"; |
| 292 | |
|
| 293 | |
} |
| 294 | |
|
| 295 | |
} |