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
9 package org.opendaylight.netconf.topology.example;
11 import com.google.common.base.Preconditions;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.List;
14 import org.opendaylight.netconf.topology.StateAggregator;
15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
18 * Aggregator implementation expecting just a single state
20 public final class ExampleSingleStateAggregator implements StateAggregator {
22 @Override public ListenableFuture<Node> combineCreateAttempts(final List<ListenableFuture<Node>> stateFutures) {
23 return getSingleFuture(stateFutures);
26 private <T> ListenableFuture<T> getSingleFuture(final List<ListenableFuture<T>> stateFutures) {
27 Preconditions.checkArgument(stateFutures.size() == 1, "Recieved multiple results, Single result is enforced here");
28 return stateFutures.get(0);
31 @Override public ListenableFuture<Node> combineUpdateAttempts(final List<ListenableFuture<Node>> stateFutures) {
32 return getSingleFuture(stateFutures);
35 @Override public ListenableFuture<Void> combineDeleteAttempts(final List<ListenableFuture<Void>> stateFutures) {
36 return getSingleFuture(stateFutures);