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