1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.api.identity.name;
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 StringToKimEntityNameInfoMapAdapter extends XmlAdapter<StringToKimEntityNameInfoMapAdapter.StringEntityNameInfoMapEntry[], Map<String, EntityName>> {
36
37
38
39
40
41
42 @Override
43 public StringEntityNameInfoMapEntry[] marshal(Map<String, EntityName> map) throws Exception {
44 if(null == map) return null;
45 StringEntityNameInfoMapEntry[] entryArray = new StringEntityNameInfoMapEntry[map.size()];
46 int i = 0;
47 for (Map.Entry<String, EntityName> e : map.entrySet()) {
48 entryArray[i] = new StringEntityNameInfoMapEntry(e.getKey(), e.getValue());
49 i++;
50 }
51 return entryArray;
52 }
53
54
55
56
57
58
59 @Override
60 public Map<String, EntityName> unmarshal(StringEntityNameInfoMapEntry[] entryArray) throws Exception {
61 if (null == entryArray) return null;
62 Map<String, EntityName> resultMap = new HashMap<String, EntityName>(entryArray.length);
63 for (int i = 0; i < entryArray.length; i++) {
64 StringEntityNameInfoMapEntry entry = entryArray[i];
65 resultMap.put(entry.getKey(), entry.getValue());
66 }
67 return resultMap;
68 }
69
70 public static class StringEntityNameInfoMapEntry 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 EntityName value;
79
80 @SuppressWarnings("unused")
81 @XmlAnyElement
82 private final Collection<Element> _futureElements = null;
83
84
85
86
87 public StringEntityNameInfoMapEntry() {
88 key = null;
89 value = null;
90 }
91
92 public StringEntityNameInfoMapEntry(String key, EntityName 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 EntityName getValue() {
104 return value;
105 }
106 }
107 }