2 * Copyright (c) 2014 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.controller.sal.restconf.impl.test;
10 import java.util.concurrent.ExecutionException;
11 import java.util.concurrent.Future;
12 import java.util.concurrent.TimeUnit;
13 import java.util.concurrent.TimeoutException;
14 import org.opendaylight.yangtools.yang.common.RpcResult;
16 public class DummyFuture<T> implements Future<RpcResult<T>> {
18 private final boolean cancel;
19 private final boolean isCancelled;
20 private final boolean isDone;
21 private final RpcResult<T> result;
23 public DummyFuture() {
30 private DummyFuture(final Builder<T> builder) {
31 cancel = builder.cancel;
32 isCancelled = builder.isCancelled;
33 isDone = builder.isDone;
34 result = builder.result;
38 public boolean cancel(final boolean mayInterruptIfRunning) {
43 public boolean isCancelled() {
48 public boolean isDone() {
53 public RpcResult<T> get() throws InterruptedException, ExecutionException {
58 public RpcResult<T> get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException,
63 public static class Builder<T> {
65 private boolean cancel;
66 private boolean isCancelled;
67 private boolean isDone;
68 private RpcResult<T> result;
70 public Builder<T> cancel(final boolean cancel) {
75 public Builder<T> isCancelled(final boolean isCancelled) {
76 this.isCancelled = isCancelled;
80 public Builder<T> isDone(final boolean isDone) {
85 public Builder<T> rpcResult(final RpcResult<T> result) {
90 public Future<RpcResult<T>> build() {
91 return new DummyFuture<T>(this);