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 | 0 | public MapValuesFinder(Map<String, String> keyValues) { |
33 | 0 | setKeyValues(keyValues); |
34 | 0 | } |
35 | |
|
36 | |
public void setKeyValues(Map<String, String> keyValues) { |
37 | 0 | if (keyValues == null) { |
38 | 0 | throw new IllegalArgumentException("keyValues was null"); |
39 | |
} |
40 | 0 | this.keyValues = Collections.unmodifiableMap(new HashMap<String, String>(keyValues)); |
41 | 0 | } |
42 | |
|
43 | |
@Override |
44 | |
public List<KeyValue> getKeyValues() { |
45 | 0 | final List<KeyValue> list = new ArrayList<KeyValue>(); |
46 | 0 | for (Map.Entry<String, String> entry : keyValues.entrySet()) { |
47 | 0 | list.add(new ConcreteKeyValue(entry)); |
48 | |
} |
49 | 0 | return Collections.unmodifiableList(list); |
50 | |
} |
51 | |
|
52 | |
@Override |
53 | |
public List<KeyValue> getKeyValues(boolean includeActiveOnly) { |
54 | 0 | return getKeyValues(); |
55 | |
} |
56 | |
|
57 | |
@Override |
58 | |
public Map<String, String> getKeyLabelMap() { |
59 | 0 | return keyValues; |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
public String getKeyLabel(String key) { |
64 | 0 | return keyValues.get(key); |
65 | |
} |
66 | |
|
67 | |
@Override |
68 | |
public void clearInternalCache() { |
69 | |
|
70 | 0 | } |
71 | |
} |