
org.smallibs.concurrent.promise.impl.MappedPromise 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 org.smallibs.util.FunctionWithError;
final class MappedPromise extends SolvablePromise {
MappedPromise(Promise promise, FunctionWithError super T, ? extends R> transform) {
super();
promise.onComplete(c ->
solve(c.flatmap(v -> {
try {
return Try.success(transform.apply(v));
} catch (Throwable throwable) {
return Try.failure(throwable);
}
}))
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy