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

functionalj.function.Apply Maven / Gradle / Ivy

There is a newer version: 1.0.17
Show newest version
// ============================================================================
// Copyright (c) 2017-2021 Nawapunth Manusitthipol (NawaMan - http://nawaman.net).
// ----------------------------------------------------------------------------
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// ============================================================================
package functionalj.function;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.DoubleBinaryOperator;
import java.util.function.DoubleSupplier;
import java.util.function.DoubleUnaryOperator;
import java.util.function.Function;
import java.util.function.IntBinaryOperator;
import java.util.function.IntSupplier;
import java.util.function.IntUnaryOperator;
import java.util.function.LongBinaryOperator;
import java.util.function.LongSupplier;
import java.util.function.LongUnaryOperator;
import java.util.function.Supplier;
import java.util.function.ToDoubleBiFunction;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;

import functionalj.lens.lenses.DoubleAccess;
import functionalj.lens.lenses.DoubleToDoubleAccessPrimitive;
import functionalj.lens.lenses.DoubleToIntegerAccessPrimitive;
import functionalj.lens.lenses.DoubleToLongAccessPrimitive;
import functionalj.lens.lenses.IntegerAccess;
import functionalj.lens.lenses.IntegerToDoubleAccessPrimitive;
import functionalj.lens.lenses.IntegerToIntegerAccessPrimitive;
import functionalj.lens.lenses.IntegerToLongAccessPrimitive;
import functionalj.lens.lenses.LongAccess;
import functionalj.lens.lenses.LongToDoubleAccessPrimitive;
import functionalj.lens.lenses.LongToIntegerAccessPrimitive;
import functionalj.lens.lenses.LongToLongAccessPrimitive;
import functionalj.list.FuncList;
import functionalj.map.FuncMap;
import functionalj.promise.HasPromise;
import functionalj.promise.Promise;
import functionalj.ref.Ref;
import functionalj.result.Result;
import functionalj.stream.ZipWithOption;
import functionalj.task.Task;
import lombok.val;
import nullablej.nullable.Nullable;

public interface Apply {
    
    public static  O apply(Func0 func) {
        return func.get();
    }
    public static  O apply(Ref ref) {
        return ref.value();
    }
    
    public static  O apply(Func1 func, I input) {
        return func.apply(input);
    }
    
    public static  O apply(Func2 func, I1 input1, I2 input2) {
        return func.apply(input1, input2);
    }
    public static  Func1 apply(Func2 func, I1 input1) {
        return input2 -> func.apply(input1, input2);
    }
    
    public static  O apply(Func3 func, I1 input1, I2 input2, I3 input3) {
        return func.apply(input1, input2, input3);
    }
    public static  Func2 apply(Func3 func, I1 input1) {
        return func.applyTo(input1);
    }
    public static  Func1 apply(Func3 func, I1 input1, I2 input2) {
        return func.applyTo(input1).applyTo(input2);
    }
    
    public static  O apply(Func4 func, I1 input1, I2 input2, I3 input3, I4 input4) {
        return func.apply(input1, input2, input3, input4);
    }
    public static  Func3 apply(Func4 func, I1 input1) {
        return func.applyTo(input1);
    }
    public static  Func2 apply(Func4 func, I1 input1, I2 input2) {
        return func.applyTo(input1).applyTo(input2);
    }
    public static  Func1 apply(Func4 func, I1 input1, I2 input2, I3 input3) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3);
    }
    
    public static  O apply(Func5 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5) {
        return func.apply(input1, input2, input3, input4, input5);
    }
    public static  Func4 apply(Func5 func, I1 input1) {
        return func.applyTo(input1);
    }
    public static  Func3 apply(Func5 func, I1 input1, I2 input2) {
        return func.applyTo(input1).applyTo(input2);
    }
    public static  Func2 apply(Func5 func, I1 input1, I2 input2, I3 input3) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3);
    }
    public static  Func1 apply(Func5 func, I1 input1, I2 input2, I3 input3, I4 input4) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3).applyTo(input4);
    }
    
    public static  O apply(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5, I6 input6) {
        return func.apply(input1, input2, input3, input4, input5, input6);
    }
    public static  Func5 apply(Func6 func, I1 input1) {
        return func.applyTo(input1);
    }
    public static  Func4 apply(Func6 func, I1 input1, I2 input2) {
        return func.applyTo(input1).applyTo(input2);
    }
    public static  Func3 apply(Func6 func, I1 input1, I2 input2, I3 input3) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3);
    }
    public static  Func2 apply(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3).applyTo(input4);
    }
    public static  Func1 apply(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3).applyTo(input4).applyTo(input5);
    }
    
    //== $ ==
    
    public static  O $(Supplier func) {
        return func.get();
    }
    public static  O $(Ref ref) {
        return ref.value();
    }
    
    public static  O $(Function func, I input) {
        return func.apply(input);
    }
    public static  Result $(Function func, Result input) {
        return Func1.from(func).applyTo(input);
    }
    public static  Optional $(Function func, Optional input) {
        return Func1.from(func).applyTo(input);
    }
    public static  Nullable $(Function func, Nullable input) {
        return Func1.from(func).applyTo(input);
    }
    public static  FuncList $(Function func, List input) {
        return Func1.from(func).applyTo(input);
    }
    public static  FuncMap $(Function func, Map input) {
        return Func1.from(func).applyTo(input);
    }
    public static  Func0 $(Function func, Supplier input) {
        return Func1.from(func).applyTo(input);
    }
    public static  Func1 $(Function func, Function input) {
        return Func1.from(func).applyTo(input);
    }
    public static  Promise $(Function func, HasPromise input) {
        return Func1.from(func).applyTo(input);
    }
    public static  Task $(Function func, Task input) {
        return Func1.from(func).applyTo(input);
    }
    
    public static  O $(BiFunction func, I1 input1, I2 input2) {
        return func.apply(input1, input2);
    }
    public static  Func1 $(BiFunction func, I1 input1) {
        return input2 -> func.apply(input1, input2);
    }
    public static  Result $(BiFunction func, Result input1, Result input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    public static  Optional $(BiFunction func, Optional input1, Optional input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    public static  Nullable $(BiFunction func, Nullable input1, Nullable input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    public static  FuncList $(BiFunction func, FuncList input1, FuncList input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    public static  FuncList $(BiFunction func, FuncList input1, FuncList input2, ZipWithOption option) {
        return Func2.from(func).applyTo(input1, input2, option);
    }
    public static  FuncMap $(BiFunction func, FuncMap input1, FuncMap input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    public static  FuncMap $(BiFunction func, FuncMap input1, FuncMap input2, ZipWithOption option) {
        return Func2.from(func).applyTo(input1, input2, option);
    }
    public static  Func0 $(BiFunction func, Supplier input1, Supplier input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    public static  Promise $(BiFunction func, HasPromise input1, HasPromise input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    public static  Task $(BiFunction func, Task input1, Task input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    public static  Func1 $(BiFunction func, Func1 input1, Func1 input2) {
        return Func2.from(func).applyTo(input1, input2);
    }
    
    public static  O $(Func3 func, I1 input1, I2 input2, I3 input3) {
        return func.apply(input1, input2, input3);
    }
    public static  Func2 $(Func3 func, I1 input1) {
        return func.applyTo(input1);
    }
    public static  Func1 $(Func3 func, I1 input1, I2 input2) {
        return func.applyTo(input1).applyTo(input2);
    }
    public static  Result $(Func3 func, Result input1, Result input2, Result input3) {
        return func.applyTo(input1, input2, input3);
    }
    public static  Optional $(Func3 func, Optional input1, Optional input2, Optional input3) {
        return func.applyTo(input1, input2, input3);
    }
    public static  Nullable $(Func3 func, Nullable input1, Nullable input2, Nullable input3) {
        return func.applyTo(input1, input2, input3);
    }
    public static  Func0 $(Func3 func, Supplier input1, Supplier input2, Supplier input3) {
        return func.applyTo(input1, input2, input3);
    }
    public static  Promise $(Func3 func, HasPromise input1, HasPromise input2, HasPromise input3) {
        return func.applyTo(input1, input2, input3);
    }
    public static  Task $(Func3 func, Task input1, Task input2, Task input3) {
        return func.applyTo(input1, input2, input3);
    }
    
    public static  O $(Func4 func, I1 input1, I2 input2, I3 input3, I4 input4) {
        return func.apply(input1, input2, input3, input4);
    }
    public static  Func3 $(Func4 func, I1 input1) {
        return func.applyTo(input1);
    }
    public static  Func2 $(Func4 func, I1 input1, I2 input2) {
        return func.applyTo(input1).applyTo(input2);
    }
    public static  Func1 $(Func4 func, I1 input1, I2 input2, I3 input3) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3);
    }
    public static  Result $(Func4 func, Result input1, Result input2, Result input3, Result input4) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Optional $(Func4 func, Optional input1, Optional input2, Optional input3, Optional input4) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Nullable $(Func4 func, Nullable input1, Nullable input2, Nullable input3, Nullable input4) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Func0 $(Func4 func, Supplier input1, Supplier input2, Supplier input3, Supplier input4) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Promise $(Func4 func, HasPromise input1, HasPromise input2, HasPromise input3, HasPromise input4) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Task $(Func4 func, Task input1, Task input2, Task input3, Task input4) {
        return func.applyTo(input1, input2, input3, input4);
    }
    
    public static  Func1 $(
            Func1 func,
            Func1 input1) {
        return input -> {
            val value1 = input1.apply(input);
            return func.apply(value1);
        };
    }
    public static  Func1 $(
            Func2 func,
            Func1     input1,
            Func1     input2) {
        return input -> {
            val value1 = input1.apply(input);
            val value2 = input2.apply(input);
            return func.apply(value1, value2);
        };
    }
    public static  Func1 $(
            Func3 func,
            Func1         input1,
            Func1         input2,
            Func1         input3) {
        return input -> {
            val value1 = input1.apply(input);
            val value2 = input2.apply(input);
            val value3 = input3.apply(input);
            return func.apply(value1, value2, value3);
        };
    }
    public static  Func1 $(
            Func4 func,
            Func1            input1,
            Func1            input2,
            Func1            input3,
            Func1            input4) {
        return input -> {
            val value1 = input1.apply(input);
            val value2 = input2.apply(input);
            val value3 = input3.apply(input);
            val value4 = input4.apply(input);
            return func.apply(value1, value2, value3, value4);
        };
    }
    public static  Func1 $(
            Func5 func,
            Func1                 input1,
            Func1                 input2,
            Func1                 input3,
            Func1                 input4,
            Func1                 input5) {
        return input -> {
            val value1 = input1.apply(input);
            val value2 = input2.apply(input);
            val value3 = input3.apply(input);
            val value4 = input4.apply(input);
            val value5 = input5.apply(input);
            return func.apply(value1, value2, value3, value4, value5);
        };
    }
    public static  Func1 $(
            Func6 func,
            Func1                     input1,
            Func1                     input2,
            Func1                     input3,
            Func1                     input4,
            Func1                     input5,
            Func1                     input6) {
        return input -> {
            val value1 = input1.apply(input);
            val value2 = input2.apply(input);
            val value3 = input3.apply(input);
            val value4 = input4.apply(input);
            val value5 = input5.apply(input);
            val value6 = input6.apply(input);
            return func.apply(value1, value2, value3, value4, value5, value6);
        };
    }
    
    public static  O $(Func5 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5) {
        return func.apply(input1, input2, input3, input4, input5);
    }
    public static  Func4 $(Func5 func, I1 input1) {
        return func.applyTo(input1);
    }
    public static  Func3 $(Func5 func, I1 input1, I2 input2) {
        return func.applyTo(input1).applyTo(input2);
    }
    public static  Func2 $(Func5 func, I1 input1, I2 input2, I3 input3) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3);
    }
    public static  Func1 $(Func5 func, I1 input1, I2 input2, I3 input3, I4 input4) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3).applyTo(input4);
    }
    public static  Result $(Func4 func, Result input1, Result input2, Result input3, Result input4, Result input5) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Optional $(Func4 func, Optional input1, Optional input2, Optional input3, Optional input4, Optional input5) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Nullable $(Func4 func, Nullable input1, Nullable input2, Nullable input3, Nullable input4, Nullable input5) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Func0 $(Func4 func, Supplier input1, Supplier input2, Supplier input3, Supplier input4, Supplier input5) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Promise $(Func4 func, HasPromise input1, HasPromise input2, HasPromise input3, HasPromise input4, HasPromise input5) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Task $(Func4 func, Task input1, Task input2, Task input3, Task input4, Task input5) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Func1 $(Func4 func, Func1 input1, Func1 input2, Func1 input3, Func1 input4, Func1 input5) {
        return func.applyTo(input1, input2, input3, input4);
    }
    
    public static  O $(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5, I6 input6) {
        return func.apply(input1, input2, input3, input4, input5, input6);
    }
    public static  Func5 $(Func6 func, I1 input1) {
        return func.applyTo(input1);
    }
    public static  Func4 $(Func6 func, I1 input1, I2 input2) {
        return func.applyTo(input1).applyTo(input2);
    }
    public static  Func3 $(Func6 func, I1 input1, I2 input2, I3 input3) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3);
    }
    public static  Func2 $(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3).applyTo(input4);
    }
    public static  Func1 $(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5) {
        return func.applyTo(input1).applyTo(input2).applyTo(input3).applyTo(input4).applyTo(input5);
    }
    public static  Result $(Func4 func, Result input1, Result input2, Result input3, Result input4, Result input5, Result input6) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Optional $(Func4 func, Optional input1, Optional input2, Optional input3, Optional input4, Optional input5, Optional input6) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Nullable $(Func4 func, Nullable input1, Nullable input2, Nullable input3, Nullable input4, Nullable input5, Nullable input6) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Func0 $(Func4 func, Supplier input1, Supplier input2, Supplier input3, Supplier input4, Supplier input5, Supplier input6) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Promise $(Func4 func, HasPromise input1, HasPromise input2, HasPromise input3, HasPromise input4, HasPromise input5, HasPromise input6) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Task $(Func4 func, Task input1, Task input2, Task input3, Task input4, Task input5, Task input6) {
        return func.applyTo(input1, input2, input3, input4);
    }
    public static  Func1 $(Func4 func, Func1 input1, Func1 input2, Func1 input3, Func1 input4, Func1 input5, Func1 input6) {
        return func.applyTo(input1, input2, input3, input4);
    }
    
    //== $$ ==
    
    /** Apply the function safely (return {@code Result}). */
    public static  Result $$(Supplier func) {
        return applySafely(func);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result $$(Ref ref) {
        return applySafely(ref);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result $$(Function func, I input) {
        return applySafely(func, input);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result $$(BiFunction func, I1 input1, I2 input2) {
        return applySafely(func, input1, input2);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result $$(Func3 func, I1 input1, I2 input2, I3 input3) {
        return applySafely(func, input1, input2, input3);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result $$(Func4 func, I1 input1, I2 input2, I3 input3, I4 input4) {
        return applySafely(func, input1, input2, input3, input4);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result $$(Func5 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5) {
        return applySafely(func, input1, input2, input3, input4, input5);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result $$(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5, I6 input6) {
        return applySafely(func, input1, input2, input3, input4, input5, input6);
    }
    
    /** Apply the function safely (return {@code Result}). */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static  Result applySafely(Supplier func) {
        if (func instanceof Func0)
            return ((Func0) func).applySafely();
        
        return Result.of(()->func.get());
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result applySafely(Ref ref) {
        return ref.asResult();
    }
    /** Apply the function safely (return {@code Result}). */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static  Result applySafely(Function func, I input) {
        if (func instanceof Func1)
            return ((Func1) func).applySafely(input);
        
        return Result.of(()->func.apply(input));
    }
    /** Apply the function safely (return {@code Result}). */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static  Result applySafely(BiFunction func, I1 input1, I2 input2) {
        if (func instanceof Func2)
            return ((Func2) func).applySafely(input1, input2);
        
        return Result.of(()->func.apply(input1, input2));
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result applySafely(Func3 func, I1 input1, I2 input2, I3 input3) {
        return func.applySafely(input1, input2, input3);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result applySafely(Func4 func, I1 input1, I2 input2, I3 input3, I4 input4) {
        return func.applySafely(input1, input2, input3, input4);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result applySafely(Func5 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5) {
        return func.applySafely(input1, input2, input3, input4, input5);
    }
    /** Apply the function safely (return {@code Result}). */
    public static  Result applySafely(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5, I6 input6) {
        return func.applySafely(input1, input2, input3, input4, input5, input6);
    }
    
    //== $$$ ==
    
    /** Apply the function safely (might throw exception). */
    public static  O applyUnsafe(Supplier func) throws Exception {
        if (func instanceof Func0)
            return ((Func0) func).applyUnsafe();
        
        return func.get();
    }
    /** Apply the function safely (might throw exception). */
    public static  O $$$(Function func, I input) throws Exception {
        if (func instanceof Func1)
            return ((Func1)func).applyUnsafe(input);
        
        return func.apply(input);
    }
    /** Apply the function safely (might throw exception). */
    public static  O $$$(BiFunction func, I1 input1, I2 input2) throws Exception {
        if (func instanceof Func2)
            return ((Func2)func).applyUnsafe(input1, input2);
        
        return func.apply(input1, input2);
    }
    /** Apply the function safely (might throw exception). */
    public static  O $$$(Func3 func, I1 input1, I2 input2, I3 input3) throws Exception {
        return func.applyUnsafe(input1, input2, input3);
    }
    /** Apply the function safely (might throw exception). */
    public static  O $$$(Func4 func, I1 input1, I2 input2, I3 input3, I4 input4) throws Exception {
        return func.applyUnsafe(input1, input2, input3, input4);
    }
    /** Apply the function safely (might throw exception). */
    public static  O $$$(Func5 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5) throws Exception {
        return func.applyUnsafe(input1, input2, input3, input4, input5);
    }
    /** Apply the function safely (might throw exception). */
    public static  O $$$(Func6 func, I1 input1, I2 input2, I3 input3, I4 input4, I5 input5, I6 input6) throws Exception {
        return func.applyUnsafe(input1, input2, input3, input4, input5, input6);
    }
    
    //== Access ==
    
    public static  Integer access(IntegerAccess access, HOST host) {
        return access.apply(host);
    }
    public static  Long access(LongAccess access, HOST host) {
        return access.apply(host);
    }
    public static  Double access(DoubleAccess access, HOST host) {
        return access.apply(host);
    }
    
    //== Primitive ==
    
    public static int getPrimitive(IntSupplier supplier) {
        return supplier.getAsInt();
    }
    public static long getPrimitive(LongSupplier supplier) {
        return supplier.getAsLong();
    }
    public static double getPrimitive(DoubleSupplier supplier) {
        return supplier.getAsDouble();
    }
    
    public static int applyPrimitive(IntUnaryOperator function, int value) {
        return function.applyAsInt(value);
    }
    public static long applyPrimitive(LongUnaryOperator function, long value) {
        return function.applyAsLong(value);
    }
    public static double applyPrimitive(DoubleUnaryOperator function, double value) {
        return function.applyAsDouble(value);
    }
    
    public static double applyPrimitive(ToDoubleFunction function, int value) {
        return function.applyAsDouble(value);
    }
    public static double applyPrimitive(ToDoubleFunction function, long value) {
        return function.applyAsDouble(value);
    }
    public static double applyPrimitive(ToDoubleFunction function, double value) {
        return function.applyAsDouble(value);
    }
    
    public static double applyPrimitive(ToIntFunction function, int value) {
        return function.applyAsInt(value);
    }
    public static double applyPrimitive(ToIntFunction function, long value) {
        return function.applyAsInt(value);
    }
    public static double applyPrimitive(ToIntFunction function, double value) {
        return function.applyAsInt(value);
    }
    
    public static  int applyPrimitive(ToIntFunction function, HOST value) {
        return function.applyAsInt(value);
    }
    public static  long applyPrimitive(ToLongFunction function, HOST value) {
        return function.applyAsLong(value);
    }
    public static  double applyPrimitive(ToDoubleFunction function, HOST value) {
        return function.applyAsDouble(value);
    }
    
    public static int applyPrimitive(IntBinaryOperator function, int value1, int value2) {
        return function.applyAsInt(value1, value2);
    }
    public static long applyPrimitive(LongBinaryOperator function, long value1, long value2) {
        return function.applyAsLong(value1, value2);
    }
    public static double applyPrimitive(DoubleBinaryOperator function, double value1, double value2) {
        return function.applyAsDouble(value1, value2);
    }
    
    public static double applyPrimitive(ToDoubleBiFunction function, int value1, double value2) {
        return function.applyAsDouble(value1, value2);
    }
    
    public static int accessPrimitive(IntegerToIntegerAccessPrimitive access, int host) {
        return access.applyAsInt(host);
    }
    public static int accessPrimitive(LongToIntegerAccessPrimitive access, long host) {
        return access.applyLongToInt(host);
    }
    public static int accessPrimitive(DoubleToIntegerAccessPrimitive access, double host) {
        return access.applyDoubleToInt(host);
    }
    
    public static long accessPrimitive(IntegerToLongAccessPrimitive access, int host) {
        return access.applyIntToLong(host);
    }
    public static long accessPrimitive(LongToLongAccessPrimitive access, long host) {
        return access.applyAsLong(host);
    }
    public static long accessPrimitive(DoubleToLongAccessPrimitive access, double host) {
        return access.applyAsLong(host);
    }
    
    public static double accessPrimitive(IntegerToDoubleAccessPrimitive access, int host) {
        return access.applyIntToDouble(host);
    }
    public static double accessPrimitive(LongToDoubleAccessPrimitive access, long host) {
        return access.applyLongToDouble(host);
    }
    public static double accessPrimitive(DoubleToDoubleAccessPrimitive access, double host) {
        return access.applyAsDouble(host);
    }
    
}