1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.r2.common.util;
18
19 import java.util.List;
20 import java.util.Map;
21 import org.kuali.student.r2.common.dto.AttributeInfo;
22
23
24
25
26
27
28 public class AttributeHelper {
29
30 private List<AttributeInfo> attrs;
31
32 public AttributeHelper(List<AttributeInfo> attrs) {
33 this.attrs = attrs;
34 }
35
36 public void putAll(Map<String, String> map) {
37
38 for(Map.Entry<String, String> entry: map.entrySet()) {
39 this.put(entry.getKey(), entry.getValue());
40 }
41 }
42
43 public String get(String key) {
44 for (AttributeInfo attr : attrs) {
45 if (attr.getKey().equals(key)) {
46 return attr.getValue();
47 }
48 }
49 return null;
50 }
51
52 public void put(String key, String value) {
53 for (AttributeInfo attr : attrs) {
54 if (attr.getKey().equals(key)) {
55 attr.setValue(value);
56 return;
57 }
58 }
59 AttributeInfo info = new AttributeInfo(key, value);
60 attrs.add(info);
61 }
62 }