Java Futures

Bridge gaps and help overcome inconveniences with CompletableFuture. This module includes, among other features, methods to collect the results of multiple futures into a list, provides equivalent alternatives to CompletableFuture’s monadic methods (thenApply, thenCompose, etc.) that can deal with checked exceptions, and methods for asynchronous “try-with-resources” constructs.

Лицензия

Лицензия

Категории

Категории

Java Языки программирования Сеть
Группа

Группа

net.florianschoppmann.java
Идентификатор

Идентификатор

java-futures
Последняя версия

Последняя версия

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Java Futures
Bridge gaps and help overcome inconveniences with CompletableFuture. This module includes, among other features, methods to collect the results of multiple futures into a list, provides equivalent alternatives to CompletableFuture’s monadic methods (thenApply, thenCompose, etc.) that can deal with checked exceptions, and methods for asynchronous “try-with-resources” constructs.
Ссылка на сайт

Ссылка на сайт

https://github.com/fschopp/java-futures
Система контроля версий

Система контроля версий

https://github.com/fschopp/java-futures

Скачать java-futures

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.florianschoppmann.java/java-futures/ -->
<dependency>
    <groupId>net.florianschoppmann.java</groupId>
    <artifactId>java-futures</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.florianschoppmann.java/java-futures/
implementation 'net.florianschoppmann.java:java-futures:1.1.0'
// https://jarcasting.com/artifacts/net.florianschoppmann.java/java-futures/
implementation ("net.florianschoppmann.java:java-futures:1.1.0")
'net.florianschoppmann.java:java-futures:jar:1.1.0'
<dependency org="net.florianschoppmann.java" name="java-futures" rev="1.1.0">
  <artifact name="java-futures" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.florianschoppmann.java', module='java-futures', version='1.1.0')
)
libraryDependencies += "net.florianschoppmann.java" % "java-futures" % "1.1.0"
[net.florianschoppmann.java/java-futures "1.1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
com.google.code.findbugs : jsr305 Необязательный jar 3.0.1

test (1)

Идентификатор библиотеки Тип Версия
org.testng : testng jar 6.9.10

Модули Проекта

Данный проект не имеет модулей.

Bridge gaps and help overcome inconveniences with CompletableFuture.

Status

Build Status Maven Central

Overview

  • requires Java 8
  • methods that collect the results of multiple completion stages into a List future, both with short-circuit semantics (fail early if an input completion stage fails) and without (guaranteed not to be completed while there are uncompleted input stages)
  • equivalent methods for supplyAsync, thenApply, thenCompose, etc. that accept functions throwing checked exceptions
  • method similar to Scala’s Promise#completeWith
  • method for unwrapping CompletionException
  • method for exception mapping
  • methods for dealing with asynchronous “try-with-resources” scenarios
  • tests have virtually full code coverage

License

Revised BSD (3-Clause) License

Binary Releases

Published releases (compiled for Java 8 and up) are available on Maven Central.

<dependency>
    <groupId>net.florianschoppmann.java</groupId>
    <artifactId>java-futures</artifactId>
    <version>1.1.0</version>
</dependency>

Documentation

For current snapshot:

Release documentation is available by replacing “snapshot” in the URL by the respective version number (such as “1.1.0”).

Usage Examples

The following examples show some use cases of class Futures provided by this project.

Collect the results of multiple completion stages into a List future

CompletableFuture<Integer> sum(Set<CompletionStage<Integer>> set) {
    return Futures.shortCircuitCollect(set)
        .thenApply(list -> list.stream().mapToInt(Integer::intValue).sum());
}

Equivalent methods allowing for checked exceptions

CompletableFuture<Long> fileSize(CompletionStage<Path> filePathStage,
        Executor executor) {
    // Note that Files#size(Path) throws an IOException, hence it would have to
    // be wrapped in the lambda expression passed to
    // CompletionStage#thenApply(Function).
    return Futures.thenApplyAsync(filePathStage, Files::size, executor);
}

Версии библиотеки

Версия
1.1.0
1.0.0