1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.api.doctype; |
17 | |
|
18 | |
import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter; |
19 | |
|
20 | |
import javax.xml.bind.annotation.adapters.XmlAdapter; |
21 | |
import java.util.ArrayList; |
22 | |
import java.util.HashMap; |
23 | |
import java.util.List; |
24 | |
import java.util.Map; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | 0 | class DocumentTypePolicyMapAdapter extends XmlAdapter<MapStringStringAdapter.StringMapEntryList, Map<DocumentTypePolicy, String>> { |
33 | |
|
34 | |
@Override |
35 | |
public MapStringStringAdapter.StringMapEntryList marshal(Map<DocumentTypePolicy, String> map) { |
36 | 0 | List<MapStringStringAdapter.StringMapEntry> entries = new ArrayList<MapStringStringAdapter.StringMapEntry>(); |
37 | 0 | if (map != null) { |
38 | 0 | for (DocumentTypePolicy policy : map.keySet()) { |
39 | 0 | entries.add(new MapStringStringAdapter.StringMapEntry(policy.getCode(), map.get(policy))); |
40 | |
} |
41 | |
} |
42 | 0 | return new MapStringStringAdapter.StringMapEntryList(entries); |
43 | |
} |
44 | |
|
45 | |
@Override |
46 | |
public Map<DocumentTypePolicy, String> unmarshal(MapStringStringAdapter.StringMapEntryList entryList) { |
47 | 0 | Map<DocumentTypePolicy, String> policies = new HashMap<DocumentTypePolicy, String>(); |
48 | 0 | if (entryList != null) { |
49 | 0 | for (MapStringStringAdapter.StringMapEntry entry : entryList.getEntries()) { |
50 | 0 | DocumentTypePolicy policy = DocumentTypePolicy.fromCode(entry.getKey()); |
51 | |
|
52 | |
|
53 | 0 | if (policy != null) { |
54 | 0 | policies.put(policy, entry.getValue()); |
55 | |
} |
56 | 0 | } |
57 | |
} |
58 | 0 | return policies; |
59 | |
} |
60 | |
|
61 | |
} |