
org.smallibs.concurrent.promise.impl.FlatMappedPromise Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hpas Show documentation
Show all versions of hpas Show documentation
Functional ADT And Asynchronous library in Java
/*
* HPAS
* https://github.com/d-plaindoux/hpas
*
* Copyright (c) 2016-2017 Didier Plaindoux
* Licensed under the LGPL2 license.
*/
package org.smallibs.concurrent.promise.impl;
import org.smallibs.concurrent.promise.Promise;
import org.smallibs.data.Try;
import java.util.function.Function;
final class FlatMappedPromise extends SolvablePromise {
FlatMappedPromise(Promise promise, Function> transform) {
super();
promise.onComplete(response ->
response.onSuccess(s -> transform.apply(s).onComplete(this::solve))
.onFailure(f -> this.solve(Try.failure(f)))
);
}
}