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.mdsal.binding.dom.adapter;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Collection;
13 import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
14 import org.opendaylight.mdsal.binding.api.DataTreeModification;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.mdsal.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 it as {@link DOMDataTreeChangeListener}
22 * and translated DOM events to their Binding equivalent.
24 class BindingDOMDataTreeChangeListenerAdapter<T extends DataObject> implements DOMDataTreeChangeListener {
26 private final BindingToNormalizedNodeCodec codec;
27 private final DataTreeChangeListener<T> listener;
28 private final LogicalDatastoreType store;
30 BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec,
31 final DataTreeChangeListener<T> listener, final LogicalDatastoreType store) {
32 this.codec = requireNonNull(codec);
33 this.listener = requireNonNull(listener);
34 this.store = requireNonNull(store);
38 public void onDataTreeChanged(final Collection<DataTreeCandidate> domChanges) {
39 final Collection<DataTreeModification<T>> bindingChanges = LazyDataTreeModification.from(codec, domChanges,
41 listener.onDataTreeChanged(bindingChanges);
45 public void onInitialData() {
46 listener.onInitialData();