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

com.fluxtion.ext.streaming.builder.factory.TestBuilder Maven / Gradle / Ivy

There is a newer version: 2.10.50
Show newest version
/*
 * Copyright (c) 2020, V12 Technology Ltd.
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the Server Side Public License, version 1,
 * as published by MongoDB, Inc.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Server Side Public License for more details.
 *
 * You should have received a copy of the Server Side Public License
 * along with this program.  If not, see 
 * .
 */
package com.fluxtion.ext.streaming.builder.factory;

import com.fluxtion.api.partition.LambdaReflection.MethodReferenceReflection;
import com.fluxtion.api.partition.LambdaReflection.SerializableBiFunction;
import com.fluxtion.api.partition.LambdaReflection.SerializableFunction;
import com.fluxtion.api.partition.LambdaReflection.SerializableQuadFunction;
import com.fluxtion.api.partition.LambdaReflection.SerializableTriFunction;
import com.fluxtion.ext.streaming.api.Test;
import com.fluxtion.ext.streaming.api.Wrapper;
import com.fluxtion.ext.streaming.builder.stream.StreamFunctionCompiler;
import com.fluxtion.ext.streaming.api.stream.Argument;
import static com.fluxtion.ext.streaming.api.stream.Argument.arg;

/**
 *
 * @author Greg Higgins [email protected]
 */
public class TestBuilder {

    /**
     * Build a {@link Test} function with nary inputs
     * @param test the test function to apply
     * @param args
     * @return 
     */
    public static Test test(MethodReferenceReflection test, Argument... args){
        final Object mapperInstance = test.captured().length == 0 ? null : test.captured()[0];
        StreamFunctionCompiler builder = StreamFunctionCompiler.test(mapperInstance, test.method(), args);
        final Wrapper wrapper = builder.build();
        wrapper.alwaysReset(false);
        return (Test) wrapper;
    }
    
    public static  Test test(SerializableFunction test,
            Argument arg1
    ) {
        return test((MethodReferenceReflection)test, arg1);
    }

    public static  Test test(SerializableFunction test,
            SerializableFunction arg1
    ) {
        return test(test, arg(arg1) );
    }
    
    public static  Test test(SerializableBiFunction test,
            Argument arg1, 
            Argument arg2
    ) {
        return test((MethodReferenceReflection)test, arg1, arg2);
    }

    public static  Test test(SerializableBiFunction test,
            SerializableFunction arg1, 
            SerializableFunction arg2 
    ) {
        return test(test, arg(arg1), arg(arg2));
    }
    
    
    public static  Test test(SerializableTriFunction test,
            Argument arg1, 
            Argument arg2, 
            Argument arg3
    ) {
        return test((MethodReferenceReflection)test, arg1, arg2, arg3);
    }

    public static  Test test(SerializableTriFunction test,
            SerializableFunction arg1, 
            SerializableFunction arg2, 
            SerializableFunction arg3
    ) {
        return test(test, arg(arg1), arg(arg2), arg(arg3));
    }

    public static  Test test(SerializableQuadFunction test,
            Argument arg1, 
            Argument arg2, 
            Argument arg3, 
            Argument arg4
    ) {
        return test((MethodReferenceReflection)test, arg1, arg2, arg3, arg4);
    }
    
    public static  Test test(SerializableQuadFunction test,
            SerializableFunction arg1, 
            SerializableFunction arg2, 
            SerializableFunction arg3,
            SerializableFunction arg4
    ) {
        return test((MethodReferenceReflection)test, arg(arg1), arg(arg2), arg(arg3), arg(arg4));
    }
    
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy