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