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