Merge "Fixed bug when Binding-Aware Data Change Listeners we're not triggered."
[controller.git] / opendaylight / md-sal / sal-common-impl / src / main / java / org / opendaylight / controller / md / sal / common / impl / service / RootedChangeSet.java
1 package org.opendaylight.controller.md.sal.common.impl.service;
2
3 import java.util.HashMap;
4 import java.util.HashSet;
5 import java.util.Map;
6 import java.util.Map.Entry;
7 import java.util.Set;
8
9 import org.opendaylight.yangtools.concepts.Path;
10
11 public class RootedChangeSet<P extends Path<P>,D> {
12
13     private final P root;
14     private final Map<P,D> original;
15     private final Map<P,D> created = new HashMap<>();
16     private final Map<P,D> updated = new HashMap<>();
17     private final Set<P> removed = new HashSet<>();
18
19
20
21     public RootedChangeSet(P root,Map<P, D> original) {
22         super();
23         this.root = root;
24         this.original = original;
25     }
26
27     protected P getRoot() {
28         return root;
29     }
30
31     protected Map<P, D> getOriginal() {
32         return original;
33     }
34
35     protected Map<P, D> getCreated() {
36         return created;
37     }
38
39     protected Map<P, D> getUpdated() {
40         return updated;
41     }
42
43     protected Set<P> getRemoved() {
44         return removed;
45     }
46
47     public void addCreated(Map<P,D> created) {
48         this.created.putAll(created);
49     }
50
51     public void addCreated(Entry<P,D> entry) {
52         created.put(entry.getKey(), entry.getValue());
53     }
54
55     public void addUpdated(Entry<P,D> entry) {
56         updated.put(entry.getKey(), entry.getValue());
57     }
58
59     public void addRemoval(P path) {
60         removed.add(path);
61     }
62
63     public boolean isChange() {
64         return !created.isEmpty() || !updated.isEmpty() || !removed.isEmpty();
65     }
66 }