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

com.fluxtion.runtime.dataflow.helpers.GroupingFactory Maven / Gradle / Ivy

There is a newer version: 9.7.4
Show newest version
package com.fluxtion.runtime.dataflow.helpers;

import com.fluxtion.runtime.annotations.builder.AssignToField;
import com.fluxtion.runtime.dataflow.aggregate.AggregateFlowFunction;
import com.fluxtion.runtime.dataflow.aggregate.function.AggregateIdentityFlowFunction;
import com.fluxtion.runtime.dataflow.aggregate.function.AggregateToListFlowFunction;
import com.fluxtion.runtime.dataflow.groupby.GroupByFlowFunctionWrapper;
import com.fluxtion.runtime.partition.LambdaReflection.SerializableFunction;
import com.fluxtion.runtime.partition.LambdaReflection.SerializableSupplier;

import java.util.List;

public class GroupingFactory> {
    private final SerializableFunction keyFunction;
    private final SerializableSupplier aggregateFunctionSupplier;

    public GroupingFactory(SerializableFunction keyFunction) {
        this.keyFunction = keyFunction;
        this.aggregateFunctionSupplier = null;
    }

    public GroupingFactory(
            @AssignToField("keyFunction") SerializableFunction keyFunction,
            @AssignToField("aggregateFunctionSupplier") SerializableSupplier aggregateFunctionSupplier) {
        this.keyFunction = keyFunction;
        this.aggregateFunctionSupplier = aggregateFunctionSupplier;
    }

    public SerializableFunction getKeyFunction() {
        return keyFunction;
    }

    public GroupByFlowFunctionWrapper, AggregateToListFlowFunction> groupByToList() {
        SerializableSupplier> list = Collectors.listFactory();
        return new GroupByFlowFunctionWrapper<>(keyFunction, Mappers::identity, list);
    }

    public GroupByFlowFunctionWrapper> groupBy() {
        SerializableSupplier> aggregateIdentityFlowFunctionSerializableSupplier = Aggregates.identityFactory();
        return new GroupByFlowFunctionWrapper<>(keyFunction, Mappers::identity, aggregateIdentityFlowFunctionSerializableSupplier);
    }

    public GroupByFlowFunctionWrapper groupingByXXX() {
        return new GroupByFlowFunctionWrapper<>(keyFunction, Mappers::identity, aggregateFunctionSupplier);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy