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

dev.vality.fraudo.utils.key.generator.CommonKeyGenerator Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package dev.vality.fraudo.utils.key.generator;

import dev.vality.fraudo.utils.TextUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;

import java.util.function.Function;

import static dev.vality.fraudo.FraudoPaymentParser.Group_byContext;
import static dev.vality.fraudo.FraudoPaymentParser.Time_windowContext;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CommonKeyGenerator {

    static  String generateKeyGroupedFunction(TerminalNode string,
                                                 ParseTree parseTree,
                                                 Time_windowContext timeWindowContext,
                                                 Group_byContext groupByContext,
                                                 Function resolve) {
        String countTarget = TextUtil.safeGetText(string);
        return new StringBuilder()
                .append(parseTree)
                .append(countTarget)
                .append(resolve.apply(countTarget))
                .append(timeWindowContext != null ? timeWindowContext.children : "")
                .append(groupByContext != null ? groupByContext.string_list().children : "")
                .toString();
    }

    static  String generateKeyGroupedTwoFieldFunction(TerminalNode firstField,
                                                         TerminalNode secondField,
                                                         ParseTree parseTree,
                                                         Time_windowContext timeWindowContext,
                                                         Group_byContext groupByContext,
                                                         Function resolve) {
        String target = TextUtil.safeGetText(firstField);
        String errorCode = TextUtil.safeGetText(secondField);
        return new StringBuilder()
                .append(parseTree)
                .append(target)
                .append(errorCode)
                .append(resolve.apply(target))
                .append(timeWindowContext != null ? timeWindowContext.children : "")
                .append(groupByContext != null ? groupByContext.string_list().children : "")
                .toString();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy