1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.keyvalues;
17
18 import org.kuali.rice.core.api.util.ConcreteKeyValue;
19 import org.kuali.rice.core.api.util.KeyValue;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26
27
28 public class MapValuesFinder implements KeyValuesFinder {
29
30 private Map<String, String> keyValues;
31
32 public MapValuesFinder(Map<String, String> keyValues) {
33 setKeyValues(keyValues);
34 }
35
36 public void setKeyValues(Map<String, String> keyValues) {
37 if (keyValues == null) {
38 throw new IllegalArgumentException("keyValues was null");
39 }
40 this.keyValues = Collections.unmodifiableMap(new HashMap<String, String>(keyValues));
41 }
42
43 @Override
44 public List<KeyValue> getKeyValues() {
45 final List<KeyValue> list = new ArrayList<KeyValue>();
46 for (Map.Entry<String, String> entry : keyValues.entrySet()) {
47 list.add(new ConcreteKeyValue(entry));
48 }
49 return Collections.unmodifiableList(list);
50 }
51
52 @Override
53 public List<KeyValue> getKeyValues(boolean includeActiveOnly) {
54 return getKeyValues();
55 }
56
57 @Override
58 public Map<String, String> getKeyLabelMap() {
59 return keyValues;
60 }
61
62 @Override
63 public String getKeyLabel(String key) {
64 return keyValues.get(key);
65 }
66
67 @Override
68 public void clearInternalCache() {
69
70 }
71 }