package org.sagebionetworks.web.client.utils;

import java.util.function.Consumer;

import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.SettableFuture;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class FutureUtils {
	public static <T> FluentFuture<T> getFuture(Consumer<AsyncCallback<T>> closure) {
		SettableFuture<T> future = SettableFuture.create();
		closure.accept(new AsyncCallback<T>() {
			@Override
			public void onFailure(Throwable caught) {
				future.setException(caught);
			}

			@Override
			public void onSuccess(T result) {
				future.set(result);
			}
		});
		return FluentFuture.from(future);
	}

	public static <T> FluentFuture<T> getFailedFuture(Throwable throwable) {
		SettableFuture<T> future = SettableFuture.create();
		future.setException(throwable);
		return future;
	}
}

@@ -673,190 +673,7 @@
 ;%0A%09%7D
-%0A%0A%09public static %3CT%3E FluentFuture%3CT%3E getFailedFuture(Throwable throwable) %7B%0A%09%09SettableFuture%3CT%3E future = SettableFuture.create();%0A%09%09future.setException(throwable);%0A%09%09return future;%0A%09%7D
 %0A%7D%0A

Remove unused getFailedFuture