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

com.fluxtion.runtime.dataflow.function.QuadPushFunction Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2025 gregory higgins.
 * 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.runtime.dataflow.function;

import com.fluxtion.runtime.annotations.PushReference;
import com.fluxtion.runtime.annotations.builder.AssignToField;
import com.fluxtion.runtime.dataflow.FlowSupplier;
import com.fluxtion.runtime.partition.LambdaReflection.SerializableQuadConsumer;
import com.fluxtion.runtime.partition.LambdaReflection.SerializableQuinConsumer;

public class QuadPushFunction extends MultiArgumentPushFunction {

    @PushReference
    protected SerializableQuinConsumer classPushMethod;
    @PushReference
    protected SerializableQuadConsumer instancePushMethod;
    protected FlowSupplier source1;
    protected FlowSupplier source2;
    protected FlowSupplier source3;
    protected FlowSupplier source4;

    public QuadPushFunction(@AssignToField("classPushMethod") SerializableQuinConsumer classPushMethod,
                            @AssignToField("source1") FlowSupplier source1,
                            @AssignToField("source2") FlowSupplier source2,
                            @AssignToField("source3") FlowSupplier source3,
                            @AssignToField("source4") FlowSupplier source4) {
        super(classPushMethod, source1, source2, source3, source4);
        this.classPushMethod = classPushMethod;
        this.source1 = source1;
        this.source2 = source2;
        this.source3 = source3;
        this.source4 = source4;
    }

    public QuadPushFunction(@AssignToField("instancePushMethod") SerializableQuadConsumer instancePushMethod,
                            @AssignToField("source1") FlowSupplier source1,
                            @AssignToField("source2") FlowSupplier source2,
                            @AssignToField("source3") FlowSupplier source3,
                            @AssignToField("source4") FlowSupplier source4) {
        super(instancePushMethod, source1, source2, source3, source4);
        this.instancePushMethod = instancePushMethod;
        this.source1 = source1;
        this.source2 = source2;
        this.source3 = source3;
        this.source4 = source4;
    }

    public void triggerOperation() {
        A a = source1.get();
        B b = source2.get();
        C c = source3.get();
        D d = source4.get();
        auditLog.info("push", auditInfo)
                .info("a", a)
                .info("b", b)
                .info("c", c)
                .info("d", d);
        if (instancePushMethod != null) {
            instancePushMethod.accept(a, b, c, d);
        } else {
            classPushMethod.accept(pushTarget, a, b, c, d);
        }
    }
}