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

io.nosqlbench.virtdata.api.composers.ComposerForIntToDoubleFunction Maven / Gradle / Ivy

Go to download

Statistical sampling library for use in virtdata libraries, based on apache commons math 4

There is a newer version: 5.17.0
Show newest version
package io.nosqlbench.virtdata.api.composers;

import io.nosqlbench.virtdata.api.FunctionType;

import java.util.function.*;

public class ComposerForIntToDoubleFunction implements FunctionComposer {

    private final IntToDoubleFunction inner;

    public ComposerForIntToDoubleFunction(IntToDoubleFunction inner) {
        this.inner = inner;
    }

    @Override
    public Object getFunctionObject() {
        return inner;
    }

    @Override
    @SuppressWarnings("unchecked")
    public FunctionComposer andThen(Object outer) {
        FunctionType functionType = FunctionType.valueOf(outer);
        switch(functionType) {
            case long_long:
                final IntToLongFunction f1 =
                        (int i) ->
                                ((LongUnaryOperator)outer).applyAsLong((int) inner.applyAsDouble(i));
                return new ComposerForIntToLongFunction(f1);
            case long_T:
                final IntFunction f2 =
                        (int i) ->
                                ((LongFunction)outer).apply((int) inner.applyAsDouble(i));
                return new ComposerForIntFunction(f2);
            case long_int:
                final IntUnaryOperator f3 =
                        (int i) ->
                                ((LongToIntFunction)outer).applyAsInt((int) inner.applyAsDouble(i));
                return new ComposerForIntUnaryOperator(f3);
            case long_double:
                final IntToDoubleFunction f4 =
                        (int i) ->
                                ((LongToDoubleFunction)outer).applyAsDouble((int) inner.applyAsDouble(i));
                return new ComposerForIntToDoubleFunction(f4);
            case int_int:
                final IntUnaryOperator f5 =
                        (int i) ->
                                ((IntUnaryOperator)outer).applyAsInt((int) inner.applyAsDouble(i));
                return new ComposerForIntUnaryOperator(f5);
            case R_T:
                final IntFunction f6 =
                        (int i) ->
                                ((Function)outer).apply(inner.applyAsDouble(i));
                return new ComposerForIntFunction(f6);
            case int_long:
                final IntToLongFunction f7 =
                        (int i) ->
                                ((IntToLongFunction)outer).applyAsLong((int) inner.applyAsDouble(i));
                return new ComposerForIntToLongFunction(f7);
            case int_double:
                final IntToDoubleFunction f8 =
                        (int i) ->
                                ((IntToDoubleFunction)outer).applyAsDouble((int) inner.applyAsDouble(i));
                return new ComposerForIntToDoubleFunction(f8);
            case int_T:
                final IntFunction f9 =
                        (int i) ->
                                ((IntFunction)outer).apply((int) inner.applyAsDouble(i));
                return new ComposerForIntFunction(f9);
            case double_double:
                final IntToDoubleFunction f10 =
                        (int i) -> ((DoubleUnaryOperator)outer).applyAsDouble(inner.applyAsDouble(i));
                return new ComposerForIntToDoubleFunction(f10);
            case double_long:
                final IntToLongFunction f11 =
                        (int i) -> ((DoubleToLongFunction)outer).applyAsLong(inner.applyAsDouble(i));
                return new ComposerForIntToLongFunction(f11);
            case double_int:
                final IntUnaryOperator f12 =
                        (int i) -> ((DoubleToIntFunction)outer).applyAsInt(inner.applyAsDouble(i));
                return new ComposerForIntUnaryOperator(f12);
            case double_T:
                final IntFunction f13 =
                        (int i) -> ((DoubleFunction)outer).apply(inner.applyAsDouble(i));
                return new ComposerForIntFunction(f13);
            default:
                throw new RuntimeException(functionType + " is not recognized");

        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy