2 * Copyright (c) 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
8 package org.opendaylight.controller.md.sal.binding.impl;
10 import static java.util.Objects.requireNonNull;
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;
21 * Adapter wrapping Binding {@link DataTreeChangeListener} and exposing
22 * it as {@link DOMDataTreeChangeListener} and translated DOM events
23 * to their Binding equivalent.
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;
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);
40 public void onDataTreeChanged(final Collection<DataTreeCandidate> domChanges) {
41 final Collection<DataTreeModification<T>> bindingChanges =
42 LazyDataTreeModification.from(codec, domChanges, store);
43 listener.onDataTreeChanged(bindingChanges);
47 public String toString() {
48 return listener.toString();