1 | |
package org.kuali.rice.kim.api.identity.type; |
2 | |
|
3 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
4 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
5 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
6 | |
import org.kuali.rice.core.api.CoreConstants; |
7 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
8 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
9 | |
import org.kuali.rice.kim.api.identity.address.EntityAddress; |
10 | |
import org.kuali.rice.kim.api.identity.address.EntityAddressContract; |
11 | |
import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation; |
12 | |
import org.kuali.rice.kim.api.identity.email.EntityEmail; |
13 | |
import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifier; |
14 | |
import org.kuali.rice.kim.api.identity.name.EntityName; |
15 | |
import org.kuali.rice.kim.api.identity.phone.EntityPhone; |
16 | |
import org.kuali.rice.kim.api.identity.phone.EntityPhoneContract; |
17 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
18 | |
import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences; |
19 | |
import org.w3c.dom.Element; |
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 | |
import java.io.Serializable; |
28 | |
import java.util.Collection; |
29 | |
import java.util.List; |
30 | |
|
31 | |
@XmlRootElement(name = EntityTypeDataDefault.Constants.ROOT_ELEMENT_NAME) |
32 | |
@XmlAccessorType(XmlAccessType.NONE) |
33 | |
@XmlType(name = EntityTypeDataDefault.Constants.TYPE_NAME, propOrder = { |
34 | |
EntityTypeDataDefault.Elements.ENTITY_TYPE_CODE, |
35 | |
EntityTypeDataDefault.Elements.DEFAULT_ADDRESS, |
36 | |
EntityTypeDataDefault.Elements.DEFAULT_EMAIL_ADDRESS, |
37 | |
EntityTypeDataDefault.Elements.DEFAULT_PHONE_NUMBER, |
38 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
39 | |
}) |
40 | 0 | public final class EntityTypeDataDefault implements ModelObjectComplete |
41 | |
{ |
42 | |
@XmlElement(name = Elements.ENTITY_TYPE_CODE, required = true) |
43 | |
private final String entityTypeCode; |
44 | |
@XmlElement(name = Elements.DEFAULT_ADDRESS, required = false) |
45 | |
private final EntityAddress defaultAddress; |
46 | |
@XmlElement(name = Elements.DEFAULT_EMAIL_ADDRESS, required = false) |
47 | |
private final EntityEmail defaultEmailAddress; |
48 | |
@XmlElement(name = Elements.DEFAULT_PHONE_NUMBER, required = false) |
49 | |
private final EntityPhone defaultPhoneNumber; |
50 | 0 | @SuppressWarnings("unused") |
51 | |
@XmlAnyElement |
52 | |
private final Collection<Element> _futureElements = null; |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | 0 | private EntityTypeDataDefault() { |
58 | 0 | this.entityTypeCode = null; |
59 | 0 | this.defaultAddress = null; |
60 | 0 | this.defaultEmailAddress = null; |
61 | 0 | this.defaultPhoneNumber = null; |
62 | |
|
63 | 0 | } |
64 | |
|
65 | 0 | public EntityTypeDataDefault(String entityTypeCode, EntityAddress defaultAddress, EntityEmail defaultEmailAddress, EntityPhone defaultPhoneNumber) { |
66 | 0 | this.entityTypeCode = entityTypeCode; |
67 | 0 | this.defaultAddress = defaultAddress; |
68 | 0 | this.defaultEmailAddress = defaultEmailAddress; |
69 | 0 | this.defaultPhoneNumber = defaultPhoneNumber; |
70 | 0 | } |
71 | |
|
72 | 0 | public EntityTypeDataDefault(Builder builder) { |
73 | 0 | this.entityTypeCode = builder.getEntityTypeCode(); |
74 | 0 | this.defaultAddress = builder.getDefaultAddress() == null ? null : builder.getDefaultAddress().build(); |
75 | 0 | this.defaultEmailAddress = builder.getDefaultEmailAddress() == null ? null : builder.getDefaultEmailAddress().build(); |
76 | 0 | this.defaultPhoneNumber = builder.getDefaultPhoneNumber() == null ? null : builder.getDefaultPhoneNumber().build(); |
77 | |
|
78 | 0 | } |
79 | |
|
80 | |
public String getEntityTypeCode() { |
81 | 0 | return this.entityTypeCode; |
82 | |
} |
83 | |
public EntityAddress getDefaultAddress() { |
84 | 0 | return this.defaultAddress; |
85 | |
} |
86 | |
|
87 | |
public EntityEmail getDefaultEmailAddress() { |
88 | 0 | return this.defaultEmailAddress; |
89 | |
} |
90 | |
|
91 | |
public EntityPhone getDefaultPhoneNumber() { |
92 | 0 | return this.defaultPhoneNumber; |
93 | |
} |
94 | |
|
95 | |
@Override |
96 | |
public int hashCode() { |
97 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
98 | |
} |
99 | |
|
100 | |
@Override |
101 | |
public boolean equals(Object object) { |
102 | 0 | return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
103 | |
} |
104 | |
|
105 | |
@Override |
106 | |
public String toString() { |
107 | 0 | return ToStringBuilder.reflectionToString(this); |
108 | |
} |
109 | |
|
110 | 0 | public final static class Builder |
111 | |
implements Serializable, ModelBuilder |
112 | |
{ |
113 | |
private String entityTypeCode; |
114 | |
private EntityAddress.Builder defaultAddress; |
115 | |
private EntityEmail.Builder defaultEmailAddress; |
116 | |
private EntityPhone.Builder defaultPhoneNumber; |
117 | |
|
118 | 0 | private Builder() { } |
119 | |
|
120 | |
public static Builder create() { |
121 | 0 | return new Builder(); |
122 | |
} |
123 | |
|
124 | |
public static Builder create(EntityTypeDataDefault immutable) { |
125 | 0 | if (immutable == null) { |
126 | 0 | throw new IllegalArgumentException("EntityTypeDataDefault is null"); |
127 | |
} |
128 | 0 | Builder builder = new Builder(); |
129 | 0 | builder.setEntityTypeCode(immutable.entityTypeCode); |
130 | 0 | if (immutable.getDefaultAddress() != null) { |
131 | 0 | builder.setDefaultAddress(EntityAddress.Builder.create(immutable.getDefaultAddress())); |
132 | |
} |
133 | 0 | if (immutable.getDefaultEmailAddress() != null) { |
134 | 0 | builder.setDefaultEmailAddress(EntityEmail.Builder.create(immutable.getDefaultEmailAddress())); |
135 | |
} |
136 | 0 | if (immutable.getDefaultPhoneNumber() != null) { |
137 | 0 | builder.setDefaultPhoneNumber(EntityPhone.Builder.create(immutable.getDefaultPhoneNumber())); |
138 | |
} |
139 | 0 | return builder; |
140 | |
} |
141 | |
|
142 | |
public static Builder create(EntityTypeDataContract contract) { |
143 | 0 | if (contract == null) { |
144 | 0 | throw new IllegalArgumentException("contract is null"); |
145 | |
} |
146 | 0 | Builder builder = new Builder(); |
147 | 0 | builder.setEntityTypeCode(contract.getEntityTypeCode()); |
148 | 0 | if (contract.getDefaultAddress() != null) { |
149 | 0 | builder.setDefaultAddress(EntityAddress.Builder.create(contract.getDefaultAddress())); |
150 | |
} |
151 | 0 | if (contract.getDefaultEmailAddress() != null) { |
152 | 0 | builder.setDefaultEmailAddress(EntityEmail.Builder.create(contract.getDefaultEmailAddress())); |
153 | |
} |
154 | 0 | if (contract.getDefaultPhoneNumber() != null) { |
155 | 0 | builder.setDefaultPhoneNumber(EntityPhone.Builder.create(contract.getDefaultPhoneNumber())); |
156 | |
} |
157 | 0 | return builder; |
158 | |
} |
159 | |
|
160 | |
public EntityTypeDataDefault build() { |
161 | 0 | return new EntityTypeDataDefault(this); |
162 | |
} |
163 | |
|
164 | |
public String getEntityTypeCode() { |
165 | 0 | return entityTypeCode; |
166 | |
} |
167 | |
|
168 | |
public void setEntityTypeCode(String entityTypeCode) { |
169 | 0 | this.entityTypeCode = entityTypeCode; |
170 | 0 | } |
171 | |
|
172 | |
public EntityAddress.Builder getDefaultAddress() { |
173 | 0 | return defaultAddress; |
174 | |
} |
175 | |
|
176 | |
public void setDefaultAddress(EntityAddress.Builder defaultAddress) { |
177 | 0 | this.defaultAddress = defaultAddress; |
178 | 0 | } |
179 | |
|
180 | |
public EntityEmail.Builder getDefaultEmailAddress() { |
181 | 0 | return defaultEmailAddress; |
182 | |
} |
183 | |
|
184 | |
public void setDefaultEmailAddress(EntityEmail.Builder defaultEmailAddress) { |
185 | 0 | this.defaultEmailAddress = defaultEmailAddress; |
186 | 0 | } |
187 | |
|
188 | |
public EntityPhone.Builder getDefaultPhoneNumber() { |
189 | 0 | return defaultPhoneNumber; |
190 | |
} |
191 | |
|
192 | |
public void setDefaultPhoneNumber(EntityPhone.Builder defaultPhoneNumber) { |
193 | 0 | this.defaultPhoneNumber = defaultPhoneNumber; |
194 | 0 | } |
195 | |
} |
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | 0 | static class Constants { |
204 | |
|
205 | |
final static String ROOT_ELEMENT_NAME = "entityTypeDataDefault"; |
206 | |
final static String TYPE_NAME = "EntityTypeDataDefaultType"; |
207 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
208 | |
|
209 | |
} |
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | 0 | static class Elements { |
217 | |
final static String ENTITY_TYPE_CODE = "entityTypeCode"; |
218 | |
final static String DEFAULT_ADDRESS = "defaultAddress"; |
219 | |
final static String DEFAULT_EMAIL_ADDRESS = "defaultEmailAddress"; |
220 | |
final static String DEFAULT_PHONE_NUMBER = "defaultPhoneNumber"; |
221 | |
|
222 | |
} |
223 | |
|
224 | |
} |