diff --git a/CHANGELOG.md b/CHANGELOG.md index a7f27aa44..e9b589af4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.10.0](https://www.github.com/googleapis/api-common-java/compare/v1.9.3...v1.10.0) (2020-07-17) + + +### Features + +* add ApiFutures.successfulAsList ([#163](https://www.github.com/googleapis/api-common-java/issues/163)) ([6af8e24](https://www.github.com/googleapis/api-common-java/commit/6af8e24a6252da7217e7c53f86cbb2b321327fc4)) + ### [1.9.3](https://www.github.com/googleapis/api-common-java/compare/v1.9.2...v1.9.3) (2020-07-01) diff --git a/build.gradle b/build.gradle index 86bb97af3..277dc137a 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ apply plugin: 'io.codearte.nexus-staging' group = "com.google.api" archivesBaseName = "api-common" -project.version = "1.9.3" // {x-version-update:api-common:current} +project.version = "1.10.0" // {x-version-update:api-common:current} sourceCompatibility = 1.7 targetCompatibility = 1.7 diff --git a/src/main/java/com/google/api/core/ApiFutures.java b/src/main/java/com/google/api/core/ApiFutures.java index d02892619..e25170fea 100644 --- a/src/main/java/com/google/api/core/ApiFutures.java +++ b/src/main/java/com/google/api/core/ApiFutures.java @@ -172,6 +172,21 @@ public ListenableFuture apply(ApiFuture apiFuture) { } }))); } + + @BetaApi + public static ApiFuture> successfulAsList( + Iterable> futures) { + return new ListenableFutureToApiFuture<>( + Futures.successfulAsList( + Iterables.transform( + futures, + new Function, ListenableFuture>() { + public ListenableFuture apply(ApiFuture apiFuture) { + return listenableFutureForApiFuture(apiFuture); + } + }))); + } + /* * @deprecated Use {@linkplain #transformAsync(ApiFuture, ApiFunction, Executor) the * overload that requires an executor}. For identical behavior, pass {@link diff --git a/src/test/java/com/google/api/core/ApiFuturesTest.java b/src/test/java/com/google/api/core/ApiFuturesTest.java index de10b7ee8..c726bf278 100644 --- a/src/test/java/com/google/api/core/ApiFuturesTest.java +++ b/src/test/java/com/google/api/core/ApiFuturesTest.java @@ -154,6 +154,17 @@ public void testAllAsList() throws Exception { assertThat(listFuture.get()).containsExactly(1, 2).inOrder(); } + @Test + public void successfulAllAsList() throws Exception { + SettableApiFuture inputFuture1 = SettableApiFuture.create(); + SettableApiFuture inputFuture2 = SettableApiFuture.create(); + ApiFuture> listFuture = + ApiFutures.successfulAsList(ImmutableList.of(inputFuture1, inputFuture2)); + inputFuture1.set(1); + inputFuture2.setException(new Exception()); + assertThat(listFuture.get()).containsExactly(1, null).inOrder(); + } + @Test public void testTransformAsync() throws Exception { ApiFuture inputFuture = ApiFutures.immediateFuture(0); diff --git a/versions.txt b/versions.txt index be1b8c5c0..ee77bfa7f 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -api-common:1.9.3:1.9.3 \ No newline at end of file +api-common:1.10.0:1.10.0 \ No newline at end of file