1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.api.identity.principal; |
17 | |
|
18 | |
import org.kuali.rice.core.api.CoreConstants; |
19 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
20 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
21 | |
import org.kuali.rice.kim.api.identity.name.EntityName; |
22 | |
import org.w3c.dom.Element; |
23 | |
|
24 | |
import javax.xml.bind.annotation.XmlAccessType; |
25 | |
import javax.xml.bind.annotation.XmlAccessorType; |
26 | |
import javax.xml.bind.annotation.XmlAnyElement; |
27 | |
import javax.xml.bind.annotation.XmlElement; |
28 | |
import javax.xml.bind.annotation.XmlRootElement; |
29 | |
import javax.xml.bind.annotation.XmlType; |
30 | |
import java.io.Serializable; |
31 | |
import java.util.Collection; |
32 | |
|
33 | |
@XmlRootElement(name = EntityNamePrincipalName.Constants.ROOT_ELEMENT_NAME) |
34 | |
@XmlAccessorType(XmlAccessType.NONE) |
35 | |
@XmlType(name = EntityNamePrincipalName.Constants.TYPE_NAME, propOrder = { |
36 | |
EntityNamePrincipalName.Elements.DEFAULT_NAME, |
37 | |
EntityNamePrincipalName.Elements.PRINCIPAL_NAME, |
38 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
39 | |
}) |
40 | 0 | public class EntityNamePrincipalName extends AbstractDataTransferObject { |
41 | |
@XmlElement(name = Elements.PRINCIPAL_NAME, required = false) |
42 | |
private final String principalName; |
43 | |
@XmlElement(name = Elements.DEFAULT_NAME, required = false) |
44 | |
private final EntityName defaultName; |
45 | 0 | @SuppressWarnings("unused") |
46 | |
@XmlAnyElement |
47 | |
private final Collection<Element> _futureElements = null; |
48 | |
|
49 | |
|
50 | 0 | private EntityNamePrincipalName() { |
51 | 0 | this.principalName = null; |
52 | 0 | this.defaultName = null; |
53 | 0 | } |
54 | |
|
55 | 0 | private EntityNamePrincipalName(Builder builder) { |
56 | 0 | this.principalName = builder.getPrincipalName(); |
57 | 0 | this.defaultName = builder.getDefaultName() == null ? null : builder.getDefaultName().build(); |
58 | 0 | } |
59 | |
|
60 | |
public String getPrincipalName() { |
61 | 0 | return principalName; |
62 | |
} |
63 | |
|
64 | |
public EntityName getDefaultName() { |
65 | 0 | return defaultName; |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | 0 | public final static class Builder |
72 | |
implements Serializable, ModelBuilder |
73 | |
{ |
74 | |
private String principalName; |
75 | |
private EntityName.Builder defaultName; |
76 | |
|
77 | |
public static Builder create() { |
78 | 0 | return new Builder(); |
79 | |
} |
80 | |
|
81 | |
public static Builder create(String principalName, EntityName.Builder defaultName) { |
82 | 0 | Builder builder = new Builder(); |
83 | 0 | builder.setPrincipalName(principalName); |
84 | 0 | builder.setDefaultName(defaultName); |
85 | 0 | return builder; |
86 | |
} |
87 | |
|
88 | |
public static Builder create(EntityNamePrincipalName immutable) { |
89 | 0 | if (immutable == null) { |
90 | 0 | throw new IllegalArgumentException("contract was null"); |
91 | |
} |
92 | 0 | Builder builder = new Builder(); |
93 | 0 | if (immutable.getDefaultName() != null) { |
94 | 0 | builder.setDefaultName(EntityName.Builder.create(immutable.getDefaultName())); |
95 | |
} |
96 | 0 | return builder; |
97 | |
} |
98 | |
|
99 | |
public String getPrincipalName() { |
100 | 0 | return principalName; |
101 | |
} |
102 | |
|
103 | |
public void setPrincipalName(String principalName) { |
104 | 0 | this.principalName = principalName; |
105 | 0 | } |
106 | |
|
107 | |
public EntityName.Builder getDefaultName() { |
108 | 0 | return defaultName; |
109 | |
} |
110 | |
|
111 | |
public void setDefaultName(EntityName.Builder defaultName) { |
112 | 0 | this.defaultName = defaultName; |
113 | 0 | } |
114 | |
|
115 | |
public EntityNamePrincipalName build() { |
116 | 0 | return new EntityNamePrincipalName(this); |
117 | |
} |
118 | |
|
119 | |
} |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | 0 | static class Constants { |
126 | |
|
127 | |
final static String ROOT_ELEMENT_NAME = "entityNamePrincipalName"; |
128 | |
final static String TYPE_NAME = "EntityNamePrincipalNameType"; |
129 | |
} |
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | 0 | static class Elements { |
137 | |
final static String DEFAULT_NAME = "defaultName"; |
138 | |
final static String PRINCIPAL_NAME = "principalName"; |
139 | |
} |
140 | |
|
141 | |
} |