All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jparkie.promise.functions.FlatMapFunction Maven / Gradle / Ivy

The newest version!
package com.github.jparkie.promise.functions;

import com.github.jparkie.promise.Function;
import com.github.jparkie.promise.Promise;
import com.github.jparkie.promise.Promises;

public abstract class FlatMapFunction implements Function {
    @Override
    public Promise call(Promise promise) {
        if (promise.isSuccessful()) {
            return flatMap(promise.get());
        } else {
            return Promises.error(promise.getError());
        }
    }

    public abstract Promise flatMap(T value);
}