-
Notifications
You must be signed in to change notification settings - Fork 510
Expand file tree
/
Copy pathValueAttribute.java
More file actions
116 lines (92 loc) · 2.21 KB
/
ValueAttribute.java
File metadata and controls
116 lines (92 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.attribute;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import com.attribute.interfaces.IValueAttribute;
import com.commonClasses.Pair;
// TODO: Auto-generated Javadoc
/**
* The Class ValueAttribute.
*
* @param <Key> the generic type
* @param <Value> the generic type
*/
public class ValueAttribute<Key, Value> implements IValueAttribute<Key, Value> {
/** The attribute key value map. */
HashMap<Key, Value> attributeKeyValueMap;
/**
* Instantiates a new value attribute.
*/
public ValueAttribute() {
this.attributeKeyValueMap = new HashMap<Key, Value>();
}
/**
* Instantiates a new value attribute.
*
* @param attributekeyValueList the attributekey value list
*/
public ValueAttribute(List<Pair<Key, Value>> attributekeyValueList) {
this();
Iterator<Pair<Key, Value>> it = attributekeyValueList.listIterator();
while (it.hasNext()) {
Pair<Key, Value> next = it.next();
this.attributeKeyValueMap.put(next.getKey(), next.getValue());
}
}
/**
* Sets the attribute.
*
* @param key the key
* @param value the value
*/
@Override
public void setAttribute(Key key, Value value) {
this.attributeKeyValueMap.put(key, value);
}
/**
* Gets the attribute.
*
* @param key the key
* @return the attribute
*/
@Override
public Value getAttribute(Key key) {
return this.attributeKeyValueMap.get(key);
}
/**
* Gets the attribute keys.
*
* @return the attribute keys
*/
@Override
public List<Key> getAttributeKeys() {
List<Key> attributeKeys = new ArrayList<Key>();
Iterator<Key> it = this.attributeKeyValueMap.keySet().iterator();
while (it.hasNext()) {
attributeKeys.add(it.next());
}
return attributeKeys;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Iterator<Key> it = this.attributeKeyValueMap.keySet().iterator();
while (it.hasNext()) {
Key next = it.next();
Value value = this.attributeKeyValueMap.get(next);
sb.append(next);
sb.append(": ");
sb.append(value);
if (it.hasNext()) {
sb.append(", ");
}
}
return sb.toString();
}
}