2 * Copyright (c) 2016 CableLabs 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
8 package org.opendaylight.unimgr.api;
10 import java.util.Collection;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
14 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
15 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
16 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
20 * abstract class for unimgr data tree changes.
21 * @author mohamed el-serngawy
22 * @param <D> extended data object
24 public abstract class UnimgrDataTreeChangeListener<D extends DataObject> implements DataTreeChangeListener<D>, AutoCloseable {
26 protected DataBroker dataBroker;
28 public UnimgrDataTreeChangeListener(final DataBroker dataBroker) {
29 this.dataBroker = dataBroker;
33 * Basic Implementation of DataTreeChange Listener to execute add, update or remove command
34 * based on the data object modification type.
37 public void onDataTreeChanged(Collection<DataTreeModification<D>> collection) {
38 for (final DataTreeModification<D> change : collection) {
39 final DataObjectModification<D> root = change.getRootNode();
40 switch (root.getModificationType()) {
41 case SUBTREE_MODIFIED:
55 * method should implements the added data object command
56 * @param newDataObject
58 public abstract void add(DataTreeModification<D> newDataObject);
61 * method should implements the removed data object command
62 * @param removedDataObject
64 public abstract void remove(DataTreeModification<D> removedDataObject);
67 * method should implements the updated data object command
68 * @param modifiedDataObject
70 public abstract void update(DataTreeModification<D> modifiedDataObject);