Added type parameteris.
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / rpc / RequestContextImpl.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.rpc;
9
10 import com.google.common.util.concurrent.SettableFuture;
11 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
12 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
13 import org.opendaylight.yangtools.yang.binding.DataObject;
14 import org.opendaylight.yangtools.yang.common.RpcResult;
15
16 /**
17  * @author joe
18  */
19 public class RequestContextImpl<T extends DataObject> implements RequestContext<T> {
20
21     private final RpcContext rpcContext;
22     private SettableFuture<RpcResult<T>> rpcResultFuture;
23
24     public RequestContextImpl(RpcContext rpcContext) {
25         this.rpcContext = rpcContext;
26     }
27
28     @Override
29     public void close() {
30         rpcContext.forgetRequestContext(this);
31     }
32
33     @Override
34     public SettableFuture<RpcResult<T>> getFuture() {
35         if (null == rpcResultFuture) {
36             rpcResultFuture = SettableFuture.create();
37         }
38         return rpcResultFuture;
39     }
40 }