package org.apache.seatunnel.transform.condition;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.function.BiFunction;

@Getter
@AllArgsConstructor
public enum OperateType {

    GT("gt", (leftVal, rightVal) -> leftVal.compareTo(rightVal) > 0, (leftVal, rightVal) -> false),

    LT( "lt", (leftVal, rightVal) -> leftVal.compareTo(rightVal) < 0,(leftVal, rightVal) -> false),

    EQUAL("equal", (leftVal, rightVal) -> leftVal.compareTo(rightVal) == 0, String::equals),

    GTE("gte", (leftVal, rightVal) -> leftVal.compareTo(rightVal) >= 0,(leftVal, rightVal) -> false),

    LTE("lte", (leftVal, rightVal) -> leftVal.compareTo(rightVal) <= 0,(leftVal, rightVal) -> false),

    NE("ne", (leftVal, rightVal) -> leftVal.compareTo(rightVal) != 0,(leftVal, rightVal) -> !leftVal.equals(rightVal)),


    LK("like", (leftVal, rightVal) -> false,String::contains),

    NLK("notlike", (leftVal, rightVal) -> false, (leftVal, rightVal) -> !leftVal.contains(rightVal)),

    SW("startwith", (leftVal, rightVal) -> false,String::startsWith),
    NSW("notstartwith", (leftVal, rightVal) -> false,(leftVal, rightVal) -> !leftVal.startsWith(rightVal)),

    EW("endwith", (leftVal, rightVal) -> false, String::endsWith),
    NEW("notendwith", (leftVal, rightVal) -> false, (leftVal, rightVal) -> !leftVal.endsWith(rightVal));

    private final String type;
    private final BiFunction<BigDecimal, BigDecimal, Boolean> numberFunction;
    private final BiFunction<String, String, Boolean> strFunction;

}
