dev.vality.fraudo.utils.key.generator.CommonKeyGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fraudo Show documentation
Show all versions of fraudo Show documentation
Language for describing antifraud patterns
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