Updated implementation of Netconf, fixed DOM Mountpoint
[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 public class Futures {
16
17     private Futures() {
18     }
19
20     public static <T> Future<T> immediateFuture(T result) {
21         return new ImmediateFuture<T>(result);
22     }
23
24     private static class ImmediateFuture<T> implements Future<T> {
25
26         private final T result;
27
28         public ImmediateFuture(T result) {
29             this.result = result;
30         }
31
32         @Override
33         public boolean cancel(boolean mayInterruptIfRunning) {
34             return false;
35         }
36
37         @Override
38         public boolean isCancelled() {
39             return false;
40         }
41
42         @Override
43         public boolean isDone() {
44             return true;
45         }
46
47         @Override
48         public T get() throws InterruptedException, ExecutionException {
49             return result;
50         }
51
52         @Override
53         public T get(long timeout, TimeUnit unit) throws InterruptedException,
54                 ExecutionException, TimeoutException {
55             return result;
56         }
57
58     }
59 }