Skip to content
Permalink
Browse files

Add FluentFuture.from(FluentFuture) factory method.

This follows the steps of FluentIterable.from(FluentIterable) and other
“migration aid” methods that are deprecated from inception and are just here to
point out code that is no longer needed.

RELNOTES=Added deprecated `FluentFuture.from(FluentFuture)` to point out redundant code.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=239402828
  • Loading branch information...
xalep authored and ronshapiro committed Mar 20, 2019
1 parent 71b9f37 commit f9f2807765c3f896c09e633026ef34f907ec7c48
@@ -44,6 +44,11 @@ public void testFromFluentFuture() {
assertThat(FluentFuture.from(f)).isSameAs(f);
}

public void testFromFluentFuturePassingAsNonFluent() {
ListenableFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
assertThat(FluentFuture.from(f)).isSameAs(f);
}

public void testFromNonFluentFuture() throws Exception {
ListenableFuture<String> f =
new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};
@@ -14,6 +14,8 @@

package com.google.common.util.concurrent;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -126,6 +128,17 @@ public final boolean cancel(boolean mayInterruptIfRunning) {
: new ForwardingFluentFuture<V>(future);
}

/**
* Simply returns its argument.
*
* @deprecated no need to use this
* @since NEXT
*/
@Deprecated
public static <V> FluentFuture<V> from(FluentFuture<V> future) {
return checkNotNull(future);
}

/**
* Returns a {@code Future} whose result is taken from this {@code Future} or, if this {@code
* Future} fails with the given {@code exceptionType}, from the result provided by the {@code
@@ -38,6 +38,11 @@ public void testFromFluentFuture() throws Exception {
testCase.testFromFluentFuture();
}

public void testFromFluentFuturePassingAsNonFluent() throws Exception {
com.google.common.util.concurrent.FluentFutureTest testCase = new com.google.common.util.concurrent.FluentFutureTest();
testCase.testFromFluentFuturePassingAsNonFluent();
}

public void testFromNonFluentFuture() throws Exception {
com.google.common.util.concurrent.FluentFutureTest testCase = new com.google.common.util.concurrent.FluentFutureTest();
testCase.testFromNonFluentFuture();
@@ -44,6 +44,11 @@ public void testFromFluentFuture() {
assertThat(FluentFuture.from(f)).isSameAs(f);
}

public void testFromFluentFuturePassingAsNonFluent() {
ListenableFuture<String> f = FluentFuture.from(SettableFuture.<String>create());
assertThat(FluentFuture.from(f)).isSameAs(f);
}

public void testFromNonFluentFuture() throws Exception {
ListenableFuture<String> f =
new SimpleForwardingListenableFuture<String>(immediateFuture("a")) {};
@@ -14,6 +14,8 @@

package com.google.common.util.concurrent;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -126,6 +128,17 @@ public final boolean cancel(boolean mayInterruptIfRunning) {
: new ForwardingFluentFuture<V>(future);
}

/**
* Simply returns its argument.
*
* @deprecated no need to use this
* @since NEXT
*/
@Deprecated
public static <V> FluentFuture<V> from(FluentFuture<V> future) {
return checkNotNull(future);
}

/**
* Returns a {@code Future} whose result is taken from this {@code Future} or, if this {@code
* Future} fails with the given {@code exceptionType}, from the result provided by the {@code

0 comments on commit f9f2807

Please sign in to comment.
You can’t perform that action at this time.