Clean up of binding broker implementation
[controller.git] / opendaylight / sal / yang-prototype / sal / sal-common-util / src / main / java / org / opendaylight / controller / sal / common / util / Futures.java
diff --git a/opendaylight/sal/yang-prototype/sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/Futures.java b/opendaylight/sal/yang-prototype/sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/Futures.java
new file mode 100644 (file)
index 0000000..c942159
--- /dev/null
@@ -0,0 +1,51 @@
+package org.opendaylight.controller.sal.common.util;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class Futures {
+
+       private Futures(){}
+       
+       public static <T> Future<T> immediateFuture(T result) {
+               return new ImmediateFuture<T>(result);
+       }
+       
+       private static class ImmediateFuture<T> implements Future<T> {
+
+               private final T result;
+               
+               public ImmediateFuture(T result) {
+                       this.result = result;
+               }
+               
+               @Override
+               public boolean cancel(boolean mayInterruptIfRunning) {
+                       return false;
+               }
+
+               @Override
+               public boolean isCancelled() {
+                       return false;
+               }
+
+               @Override
+               public boolean isDone() {
+                       return true;
+               }
+
+               @Override
+               public T get() throws InterruptedException, ExecutionException {
+                       return result;
+               }
+
+               @Override
+               public T get(long timeout, TimeUnit unit) throws InterruptedException,
+                               ExecutionException, TimeoutException {
+                       return result;
+               }
+               
+       }
+}