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.mo.AbstractDataTransferObject;
19 import org.w3c.dom.Element;
20
21 import javax.xml.bind.annotation.XmlAnyElement;
22 import javax.xml.bind.annotation.XmlAttribute;
23 import javax.xml.bind.annotation.XmlElement;
24 import javax.xml.bind.annotation.adapters.XmlAdapter;
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.Map;
28
29
30
31
32
33
34
35 public class StringToKimEntityNamePrincipalInfoMapAdapter extends XmlAdapter<StringToKimEntityNamePrincipalInfoMapAdapter.StringEntNmPrncpInfoMapEntry[], Map<String, EntityNamePrincipalName>> {
36
37
38
39
40
41
42 @Override
43 public StringEntNmPrncpInfoMapEntry[] marshal(Map<String, EntityNamePrincipalName> map) throws Exception {
44 if(null == map) return null;
45 StringEntNmPrncpInfoMapEntry[] entryArray = new StringEntNmPrncpInfoMapEntry[map.size()];
46 int i = 0;
47 for (Map.Entry<String, EntityNamePrincipalName> e : map.entrySet()) {
48 entryArray[i] = new StringEntNmPrncpInfoMapEntry(e.getKey(), e.getValue());
49 i++;
50 }
51 return entryArray;
52 }
53
54
55
56
57
58
59 @Override
60 public Map<String, EntityNamePrincipalName> unmarshal(StringEntNmPrncpInfoMapEntry[] entryArray) throws Exception {
61 if (null == entryArray) return null;
62 Map<String, EntityNamePrincipalName> resultMap = new HashMap<String, EntityNamePrincipalName>(entryArray.length);
63 for (int i = 0; i < entryArray.length; i++) {
64 StringEntNmPrncpInfoMapEntry entry = entryArray[i];
65 resultMap.put(entry.getKey(), entry.getValue());
66 }
67 return resultMap;
68 }
69
70 public static class StringEntNmPrncpInfoMapEntry extends AbstractDataTransferObject {
71
72 private static final long serialVersionUID = 1L;
73
74 @XmlAttribute
75 private final String key;
76
77 @XmlElement(required=true)
78 private final EntityNamePrincipalName value;
79
80 @SuppressWarnings("unused")
81 @XmlAnyElement
82 private final Collection<Element> _futureElements = null;
83
84
85
86
87 private StringEntNmPrncpInfoMapEntry() {
88 key = null;
89 value = null;
90 }
91
92 public StringEntNmPrncpInfoMapEntry(String key, EntityNamePrincipalName value) {
93 super();
94
95 this.key = key;
96 this.value = value;
97 }
98
99 public String getKey() {
100 return key;
101 }
102
103 public EntityNamePrincipalName getValue() {
104 return value;
105 }
106 }
107 }