2 * Copyright (c) 2016 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.groupbasedpolicy.sxp.ep.provider.impl.util;
10 import com.google.common.base.Optional;
11 import com.google.common.util.concurrent.FutureCallback;
12 import javax.annotation.Nullable;
13 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
14 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
15 import org.opendaylight.groupbasedpolicy.sxp.ep.provider.impl.SimpleCachedDao;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
19 * Purpose: provide general logic used by listeners
21 public final class SxpListenerUtil {
23 private SxpListenerUtil() {
24 throw new IllegalAccessError("constructing util class");
28 public static <K, V extends DataObject> void updateCachedDao(final SimpleCachedDao<K, V> valueCachedDao,
30 final DataTreeModification<V> change) {
31 final V value = change.getRootNode().getDataAfter();
32 valueCachedDao.update(key, value);
35 public static FutureCallback<Optional<?>> createTxCloseCallback(final ReadOnlyTransaction rTx) {
36 return new FutureCallback<Optional<?>>() {
38 public void onSuccess(@Nullable final Optional<?> result) {
43 public void onFailure(final Throwable t) {