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 | 5 | class DocumentTypePolicyMapAdapter extends XmlAdapter<MapStringStringAdapter.StringMapEntryList, Map<DocumentTypePolicy, String>> { |
33 | |
|
34 | |
@Override |
35 | |
public MapStringStringAdapter.StringMapEntryList marshal(Map<DocumentTypePolicy, String> map) { |
36 | 1 | List<MapStringStringAdapter.StringMapEntry> entries = new ArrayList<MapStringStringAdapter.StringMapEntry>(); |
37 | 1 | if (map != null) { |
38 | 1 | for (DocumentTypePolicy policy : map.keySet()) { |
39 | 1 | entries.add(new MapStringStringAdapter.StringMapEntry(policy.getCode(), map.get(policy))); |
40 | |
} |
41 | |
} |
42 | 1 | return new MapStringStringAdapter.StringMapEntryList(entries); |
43 | |
} |
44 | |
|
45 | |
@Override |
46 | |
public Map<DocumentTypePolicy, String> unmarshal(MapStringStringAdapter.StringMapEntryList entryList) { |
47 | 2 | Map<DocumentTypePolicy, String> policies = new HashMap<DocumentTypePolicy, String>(); |
48 | 2 | if (entryList != null) { |
49 | 2 | for (MapStringStringAdapter.StringMapEntry entry : entryList.getEntries()) { |
50 | 2 | DocumentTypePolicy policy = DocumentTypePolicy.fromCode(entry.getKey()); |
51 | |
|
52 | |
|
53 | 2 | if (policy != null) { |
54 | 2 | policies.put(policy, entry.getValue()); |
55 | |
} |
56 | 2 | } |
57 | |
} |
58 | 2 | return policies; |
59 | |
} |
60 | |
|
61 | |
} |