Fix checkstyle if-statements must use braces sal-common-util
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / sal / common / util / Futures.java
1 /*
2  * Copyright (c) 2013 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.controller.sal.common.util;
9
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
15 /**
16  * @deprecated Use {@link com.google.common.util.concurrent.Futures} instead.
17  */
18 @Deprecated
19 public class Futures {
20
21     private Futures() {
22     }
23
24     public static <T> Future<T> immediateFuture(T result) {
25         return new ImmediateFuture<T>(result);
26     }
27
28     private static class ImmediateFuture<T> implements Future<T> {
29
30         private final T result;
31
32         public ImmediateFuture(T result) {
33             this.result = result;
34         }
35
36         @Override
37         public boolean cancel(boolean mayInterruptIfRunning) {
38             return false;
39         }
40
41         @Override
42         public boolean isCancelled() {
43             return false;
44         }
45
46         @Override
47         public boolean isDone() {
48             return true;
49         }
50
51         @Override
52         public T get() throws InterruptedException, ExecutionException {
53             return result;
54         }
55
56         @Override
57         public T get(long timeout, TimeUnit unit) throws InterruptedException,
58                 ExecutionException, TimeoutException {
59             return result;
60         }
61
62     }
63 }