Add MXBean to report shard registered DTCL/DCL info
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / impl / BindingDOMDataTreeChangeListenerAdapter.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.binding.impl;
9
10 import com.google.common.base.Preconditions;
11 import java.util.Collection;
12 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
13 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
18
19 /**
20  * Adapter wrapping Binding {@link DataTreeChangeListener} and exposing
21  * it as {@link DOMDataTreeChangeListener} and translated DOM events
22  * to their Binding equivalent.
23  *
24  */
25 class BindingDOMDataTreeChangeListenerAdapter<T extends DataObject> implements DOMDataTreeChangeListener {
26
27     private final BindingToNormalizedNodeCodec codec;
28     private final DataTreeChangeListener<T> listener;
29     private final LogicalDatastoreType store;
30
31     BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec, final DataTreeChangeListener<T> listener,
32             final LogicalDatastoreType store) {
33         this.codec = Preconditions.checkNotNull(codec);
34         this.listener = Preconditions.checkNotNull(listener);
35         this.store = Preconditions.checkNotNull(store);
36     }
37
38     @Override
39     public void onDataTreeChanged(final Collection<DataTreeCandidate> domChanges) {
40         final Collection<DataTreeModification<T>> bindingChanges = LazyDataTreeModification.from(codec, domChanges, store);
41         listener.onDataTreeChanged(bindingChanges);
42     }
43
44     @Override
45     public String toString() {
46         return listener.toString();
47     }
48 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.