2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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.api;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ForwardingObject;
13 import com.google.common.collect.Iterables;
14 import java.util.Collection;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
17 final class DataChangeListenerAdapter<T extends DataObject> extends ForwardingObject
18 implements ClusteredDataTreeChangeListener<T> {
19 private final DataChangeListener<T> delegate;
21 DataChangeListenerAdapter(final DataChangeListener<T> delegate) {
22 this.delegate = requireNonNull(delegate);
26 public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
27 delegate.dataChanged(changes.iterator().next().getRootNode().dataBefore(),
28 Iterables.getLast(changes).getRootNode().dataAfter());
32 public void onInitialData() {
33 delegate.dataChanged(null, null);
37 protected DataChangeListener<T> delegate() {