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 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 @SuppressWarnings("unused")
46 @XmlAnyElement
47 private final Collection<Element> _futureElements = null;
48
49
50 private EntityNamePrincipalName() {
51 this.principalName = null;
52 this.defaultName = null;
53 }
54
55 private EntityNamePrincipalName(Builder builder) {
56 this.principalName = builder.getPrincipalName();
57 this.defaultName = builder.getDefaultName() == null ? null : builder.getDefaultName().build();
58 }
59
60 public String getPrincipalName() {
61 return principalName;
62 }
63
64 public EntityName getDefaultName() {
65 return defaultName;
66 }
67
68
69
70
71 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 return new Builder();
79 }
80
81 public static Builder create(String principalName, EntityName.Builder defaultName) {
82 Builder builder = new Builder();
83 builder.setPrincipalName(principalName);
84 builder.setDefaultName(defaultName);
85 return builder;
86 }
87
88 public static Builder create(EntityNamePrincipalName immutable) {
89 if (immutable == null) {
90 throw new IllegalArgumentException("contract was null");
91 }
92 Builder builder = new Builder();
93 if (immutable.getDefaultName() != null) {
94 builder.setDefaultName(EntityName.Builder.create(immutable.getDefaultName()));
95 }
96 return builder;
97 }
98
99 public String getPrincipalName() {
100 return principalName;
101 }
102
103 public void setPrincipalName(String principalName) {
104 this.principalName = principalName;
105 }
106
107 public EntityName.Builder getDefaultName() {
108 return defaultName;
109 }
110
111 public void setDefaultName(EntityName.Builder defaultName) {
112 this.defaultName = defaultName;
113 }
114
115 public EntityNamePrincipalName build() {
116 return new EntityNamePrincipalName(this);
117 }
118
119 }
120
121
122
123
124
125 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 static class Elements {
137 final static String DEFAULT_NAME = "defaultName";
138 final static String PRINCIPAL_NAME = "principalName";
139 }
140
141 }