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