Skip to content

Commit

Permalink
Add FluentFuture.from(FluentFuture) factory method.
Browse files Browse the repository at this point in the history
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
tatintart authored and ronshapiro committed Mar 29, 2019
1 parent 71b9f37 commit f9f2807
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
Expand Up @@ -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")) {};
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -126,6 +128,17 @@ public static <V> FluentFuture<V> from(ListenableFuture<V> future) {
: 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
Expand Down
Expand Up @@ -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();
Expand Down
Expand Up @@ -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")) {};
Expand Down
13 changes: 13 additions & 0 deletions guava/src/com/google/common/util/concurrent/FluentFuture.java
Expand Up @@ -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;
Expand Down Expand Up @@ -126,6 +128,17 @@ public static <V> FluentFuture<V> from(ListenableFuture<V> future) {
: 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
Expand Down

0 comments on commit f9f2807

Please sign in to comment.