3c66ab006dcc69530e41f41424097357712f2ed4
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / callback / SuccessCallback.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.impl.callback;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
13 import org.opendaylight.yangtools.yang.common.RpcResult;
14
15 public abstract class SuccessCallback<I, O> extends BaseCallback<I, O> {
16
17     public SuccessCallback(DeviceContext deviceContext, RequestContext<O> requestContext,
18             ListenableFuture<RpcResult<I>> futureResultFromOfLib) {
19         super(deviceContext, requestContext, futureResultFromOfLib);
20     }
21
22     protected void processSuccess(final RpcResult<I> rpcResult) {
23         getRequestContext().getFuture().set(transform(rpcResult));
24     }
25
26
27     abstract public RpcResult<O> transform(RpcResult<I> rpcResult);
28 }