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

org.smallibs.util.FunctionsHelper Maven / Gradle / Ivy

There is a newer version: 0.11.0
Show newest version
/*
 * HPAS
 * https://github.com/d-plaindoux/hpas
 *
 * Copyright (c) 2016-2017 Didier Plaindoux
 * Licensed under the LGPL2 license.
 */

package org.smallibs.util;

import org.smallibs.data.Try;

import java.util.function.Function;

public interface FunctionsHelper {

    static  FunctionWithError fromFunction(Function function) {
        return function::apply;
    }

    static  Function> toFunction(FunctionWithError function) {
        return t -> {
            try {
                return Try.success(function.apply(t));
            } catch (Throwable throwable) {
                return Try.failure(throwable);
            }
        };
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy