2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.md.sal.common.impl.service;
11 import java.util.HashMap;
12 import java.util.HashSet;
14 import java.util.Map.Entry;
17 import org.opendaylight.yangtools.concepts.Path;
19 public class RootedChangeSet<P extends Path<P>,D> {
22 private final Map<P,D> original;
23 private final Map<P,D> created = new HashMap<>();
24 private final Map<P,D> updated = new HashMap<>();
25 private final Set<P> removed = new HashSet<>();
29 public RootedChangeSet(P root,Map<P, D> original) {
32 this.original = original;
35 protected P getRoot() {
39 protected Map<P, D> getOriginal() {
43 protected Map<P, D> getCreated() {
47 protected Map<P, D> getUpdated() {
51 protected Set<P> getRemoved() {
55 public void addCreated(Map<P,D> created) {
56 this.created.putAll(created);
59 public void addCreated(Entry<P,D> entry) {
60 created.put(entry.getKey(), entry.getValue());
63 public void addUpdated(Entry<P,D> entry) {
64 updated.put(entry.getKey(), entry.getValue());
67 public void addRemoval(P path) {
71 public boolean isChange() {
72 return !created.isEmpty() || !updated.isEmpty() || !removed.isEmpty();