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 DataListenerAdapter<T extends DataObject> extends ForwardingObject
18 implements ClusteredDataTreeChangeListener<T> {
19 private final DataListener<T> delegate;
21 DataListenerAdapter(final DataListener<T> delegate) {
22 this.delegate = requireNonNull(delegate);
26 public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
27 delegate.dataChangedTo(Iterables.getLast(changes).getRootNode().dataAfter());
31 public void onInitialData() {
32 delegate.dataChangedTo(null);
36 protected DataListener<T> delegate() {