Merge "Bug 6050 - TcpSrcCodec is not maskable"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / rpc / AbstractRequestContext.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.ListenableFuture;
11 import com.google.common.util.concurrent.SettableFuture;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
13 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
14 import org.opendaylight.yangtools.yang.common.RpcResult;
15
16 public abstract class AbstractRequestContext<T> implements RequestContext<T> {
17     private final SettableFuture<RpcResult<T>> rpcResultFuture = SettableFuture.create();
18     private final Xid xid;
19     private long waitTimeout;
20
21     protected AbstractRequestContext(final Long xid) {
22         this.xid = xid == null ? null : new Xid(xid);
23     }
24
25     @Override
26     public final ListenableFuture<RpcResult<T>> getFuture() {
27         return rpcResultFuture;
28     }
29
30     @Override
31     public final void setResult(final RpcResult<T> result) {
32         rpcResultFuture.set(result);
33     }
34
35     @Override
36     public final Xid getXid() {
37         return xid;
38     }
39
40     @Override
41     public final long getWaitTimeout() {
42         return waitTimeout;
43     }
44
45     @Override
46     public final void setWaitTimeout(final long waitTimeout) {
47         this.waitTimeout = waitTimeout;
48     }
49 }