io.virtdata.api.composers.ComposerForIntFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-curves4 Show documentation
Show all versions of virtdata-lib-curves4 Show documentation
Statistical sampling library for use in virtualdataset libraries, based on apache commons math 4
package io.virtdata.api.composers;
import io.virtdata.api.FunctionType;
import io.virtdata.api.ValueType;
import java.util.function.*;
public class ComposerForIntFunction implements FunctionComposer> {
private final IntFunction> inner;
public ComposerForIntFunction(IntFunction> inner) {
this.inner = inner;
}
@Override
@SuppressWarnings("unchecked")
public FunctionComposer> andThen(Object outer) {
FunctionType functionType = FunctionType.valueOf(outer);
Object outv = this.inner.apply(1);
ValueType itype = ValueType.valueOfAssignableClass(outv.getClass());
switch (functionType) {
case long_long:
switch (itype) {
case LONG:
final IntToLongFunction f11 = (int i) ->
((LongUnaryOperator) outer).applyAsLong((((IntFunction) inner).apply(i)).intValue());
return new ComposerForIntToLongFunction(f11);
case DOUBLE:
final IntToLongFunction f12 = (int i) ->
((LongUnaryOperator) outer).applyAsLong((((IntFunction) inner).apply(i)).intValue());
return new ComposerForIntToLongFunction(f12);
case INT:
final IntToLongFunction f13 = (int i) ->
((LongUnaryOperator) outer).applyAsLong((((IntFunction) inner).apply(i)));
return new ComposerForIntToLongFunction(f13);
default:
final IntToLongFunction f14 = (int i) ->
((LongUnaryOperator) outer).applyAsLong(Double.valueOf((((IntFunction