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 | 0 | 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 | 0 | if(null == map) return null; |
45 | 0 | StringEntNmPrncpInfoMapEntry[] entryArray = new StringEntNmPrncpInfoMapEntry[map.size()]; |
46 | 0 | int i = 0; |
47 | 0 | for (Map.Entry<String, EntityNamePrincipalName> e : map.entrySet()) { |
48 | 0 | entryArray[i] = new StringEntNmPrncpInfoMapEntry(e.getKey(), e.getValue()); |
49 | 0 | i++; |
50 | |
} |
51 | 0 | return entryArray; |
52 | |
} |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
@Override |
60 | |
public Map<String, EntityNamePrincipalName> unmarshal(StringEntNmPrncpInfoMapEntry[] entryArray) throws Exception { |
61 | 0 | if (null == entryArray) return null; |
62 | 0 | Map<String, EntityNamePrincipalName> resultMap = new HashMap<String, EntityNamePrincipalName>(entryArray.length); |
63 | 0 | for (int i = 0; i < entryArray.length; i++) { |
64 | 0 | StringEntNmPrncpInfoMapEntry entry = entryArray[i]; |
65 | 0 | resultMap.put(entry.getKey(), entry.getValue()); |
66 | |
} |
67 | 0 | return resultMap; |
68 | |
} |
69 | |
|
70 | 0 | 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 | 0 | @SuppressWarnings("unused") |
81 | |
@XmlAnyElement |
82 | |
private final Collection<Element> _futureElements = null; |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | 0 | private StringEntNmPrncpInfoMapEntry() { |
88 | 0 | key = null; |
89 | 0 | value = null; |
90 | 0 | } |
91 | |
|
92 | |
public StringEntNmPrncpInfoMapEntry(String key, EntityNamePrincipalName value) { |
93 | 0 | super(); |
94 | |
|
95 | 0 | this.key = key; |
96 | 0 | this.value = value; |
97 | 0 | } |
98 | |
|
99 | |
public String getKey() { |
100 | 0 | return key; |
101 | |
} |
102 | |
|
103 | |
public EntityNamePrincipalName getValue() { |
104 | 0 | return value; |
105 | |
} |
106 | |
} |
107 | |
} |