Deprecate old MD-SAL APIs for removal
[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 static java.util.Objects.requireNonNull;
11
12 import java.util.Collection;
13 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
14 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
19
20 /**
21  * Adapter wrapping Binding {@link DataTreeChangeListener} and exposing
22  * it as {@link DOMDataTreeChangeListener} and translated DOM events
23  * to their Binding equivalent.
24  *
25  */
26 @Deprecated(forRemoval = true)
27 class BindingDOMDataTreeChangeListenerAdapter<T extends DataObject> implements DOMDataTreeChangeListener {
28     private final BindingToNormalizedNodeCodec codec;
29     private final DataTreeChangeListener<T> listener;
30     private final LogicalDatastoreType store;
31
32     BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec,
33             final DataTreeChangeListener<T> listener, final LogicalDatastoreType store) {
34         this.codec = requireNonNull(codec);
35         this.listener = requireNonNull(listener);
36         this.store = requireNonNull(store);
37     }
38
39     @Override
40     public void onDataTreeChanged(final Collection<DataTreeCandidate> domChanges) {
41         final Collection<DataTreeModification<T>> bindingChanges =
42                 LazyDataTreeModification.from(codec, domChanges, store);
43         listener.onDataTreeChanged(bindingChanges);
44     }
45
46     @Override
47     public String toString() {
48         return listener.toString();
49     }
50 }

©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.