-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathRefToRefDictionaryBuilder.java
More file actions
36 lines (28 loc) · 948 Bytes
/
RefToRefDictionaryBuilder.java
File metadata and controls
36 lines (28 loc) · 948 Bytes
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
package javasabr.rlib.collections.dictionary;
import java.util.Map;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
public class RefToRefDictionaryBuilder<K, V> {
MutableRefToRefDictionary<K, V> elements;
public RefToRefDictionaryBuilder() {
this.elements = DictionaryFactory.mutableRefToRefDictionary();
}
public RefToRefDictionaryBuilder<K, V> put(K key, V value) {
this.elements.put(key, value);
return this;
}
public RefToRefDictionaryBuilder<K, V> put(RefToRefDictionary<K, V> other) {
this.elements.putAll(other);
return this;
}
public RefToRefDictionaryBuilder<K, V> put(Map<K, V> other) {
for (Map.Entry<K, V> entry : other.entrySet()) {
elements.put(entry.getKey(), entry.getValue());
}
return this;
}
public RefToRefDictionary<K, V> build() {
return elements.toReadOnly();
}
}