Skip to content

Commit

Permalink
update Java doc & README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hltj committed Dec 20, 2020
1 parent 3c44a38 commit 9cf7919
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ Convenient Utilities for Vert.x [`Future`](https://vertx.io/docs/apidocs/io/vert
- [x] Java 15

### Vert.x
- [x] 3.9.1
- [x] 4.0.0 ([with `vertx-core` excluded](#with-vertx-core-excluded))
- [x] 4.0.0
- [x] 3.9.4 ([with `vertx-core` excluded](#with-vertx-core-excluded))
- [x] 3.9.3 ([with `vertx-core` excluded](#with-vertx-core-excluded))
- [x] 3.9.2 ([with `vertx-core` excluded](#with-vertx-core-excluded))
- [x] 3.9.1 ([with `vertx-core` excluded](#with-vertx-core-excluded))
- [x] 3.9.0 ([with `vertx-core` excluded](#with-vertx-core-excluded))
- [x] 3.8.5 ([with `vertx-core` excluded](#with-vertx-core-excluded))

Expand All @@ -61,26 +61,26 @@ Convenient Utilities for Vert.x [`Future`](https://vertx.io/docs/apidocs/io/vert
<dependency>
<groupId>me.hltj</groupId>
<artifactId>vertx-future-utils</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
</dependency>
```

### Gradle Kotlin DSL

``` kotlin
implementation(group = "me.hltj", name = "vertx-future-utils", version = "1.0.1")
implementation(group = "me.hltj", name = "vertx-future-utils", version = "1.1.0")
```

### Gradle Groovy DSL

``` groovy
implementation 'me.hltj:vertx-future-utils:1.0.1'
implementation 'me.hltj:vertx-future-utils:1.1.0'
```

### With `vertx-core` Excluded

The default dependent version of `io.vertx:vertx-core` is `3.9.1`, if you want to use `vertx-future-utils`
with `vertx-core` `3.8.5`/`3.9.0`/`3.9.2` to `3.9.4`/`4.0.0`, please exclude the default one.
The default dependent version of `io.vertx:vertx-core` is `4.0.0`, if you want to use `vertx-future-utils`
with `vertx-core` `3.8.5` or `3.9.0` to `3.9.4`, please exclude the default one.

<details>

Expand All @@ -90,7 +90,7 @@ with `vertx-core` `3.8.5`/`3.9.0`/`3.9.2` to `3.9.4`/`4.0.0`, please exclude the
<dependency>
<groupId>me.hltj</groupId>
<artifactId>vertx-future-utils</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>io.vertx</groupId>
Expand All @@ -103,15 +103,15 @@ with `vertx-core` `3.8.5`/`3.9.0`/`3.9.2` to `3.9.4`/`4.0.0`, please exclude the
#### for Gradle Kotlin DSL

``` kotlin
implementation(group = "me.hltj", name = "vertx-future-utils", version = "1.0.1") {
implementation(group = "me.hltj", name = "vertx-future-utils", version = "1.1.0") {
exclude(group = "io.vertx", module = "vertx-core")
}
```

#### for Gradle Groovy DSL

``` groovy
implementation 'me.hltj:vertx-future-utils:1.0.1', {
implementation 'me.hltj:vertx-future-utils:1.1.0', {
exclude group: "io.vertx", module: "vertx-core"
}
```
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/hltj/vertx/FutureExtensions.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package me.hltj.vertx;

import io.vertx.core.Future;
import lombok.experimental.ExtensionMethod;

import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;

/**
* For working with lombok {@link ExtensionMethod}.
*
* @since 1.1.0
*/
public final class FutureExtensions {

private FutureExtensions() {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/hltj/vertx/FutureUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static <T> Future<T> defaultWith(Future<T> future, Supplier<T> supplier)
* @param supplier a supplier to get the default {@code Future}
* @param <T> the type parameter of the {@code Future}
* @return the result {@code Future}
* @since 1.1.0
*/
public static <T> Future<T> flatDefaultWith(Future<T> future, Supplier<Future<T>> supplier) {
return future.flatMap(x -> x == null ? supplier.get() : Future.succeededFuture(x));
Expand Down Expand Up @@ -139,6 +140,7 @@ public static <T> Future<T> fallbackWith(Future<T> future, Function<Throwable, T
* @param function a function to get the default {@code Future}
* @param <T> the type parameter of the {@code Future}
* @return the result {@code Future}
* @since 1.1.0
*/
public static <T> Future<T> flatFallbackWith(Future<T> future, Function<Optional<Throwable>, Future<T>> function) {
return flatFallbackWith(future, function.compose(Optional::of), () -> function.apply(Optional.empty()));
Expand All @@ -152,6 +154,7 @@ public static <T> Future<T> flatFallbackWith(Future<T> future, Function<Optional
* @param supplier a function to get the default {@code Future} on success with null
* @param <T> the type parameter of the {@code Future}
* @return the result {@code Future}
* @since 1.1.0
*/
public static <T> Future<T> flatFallbackWith(
Future<T> future, Function<Throwable, Future<T>> mapper, Supplier<Future<T>> supplier
Expand All @@ -165,6 +168,7 @@ public static <T> Future<T> flatFallbackWith(
* @param future the {@code Future}
* @param <T> the type parameter of the {@code Future}
* @return the result {@code Future}
* @since 1.1.0
*/
public static <T> Future<T> nonEmpty(Future<T> future) {
return flatDefaultWith(future, () -> Future.failedFuture(new NullPointerException()));
Expand All @@ -182,6 +186,7 @@ public static <T> Future<T> nonEmpty(Future<T> future) {
* @param <T> the type parameter of the {@code Future}
* @param <R> the type parameter of the result {@code Future}
* @return the result {@code Future}
* @since 1.1.0
*/
public static <T, R> Future<R> mapSome(Future<T> future, Function<T, R> mapper) {
return future.map(v -> v == null ? null : mapper.apply(v));
Expand All @@ -199,6 +204,7 @@ public static <T, R> Future<R> mapSome(Future<T> future, Function<T, R> mapper)
* @param <T> the type parameter of the {@code Future}
* @param <R> the type parameter of the result {@code Future}
* @return the result {@code Future}
* @since 1.1.0
*/
public static <T, R> Future<R> flatMapSome(Future<T> future, Function<T, Future<R>> mapper) {
return future.flatMap(v -> v == null ? Future.succeededFuture() : mapper.apply(v));
Expand Down

0 comments on commit 9cf7919

Please sign in to comment.