/**
 *
 */
package org.springblade.datasource.transform.mysql;

import cn.hutool.core.util.ArrayUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springblade.datasource.transform.seatunnel.SeatunnelColumnType;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * @author wookvn
 */
@Getter
@AllArgsConstructor
public enum MysqlToSeatunnelEnum {

    STRING(new String[]{"varchar", "text", "char", "longtext"}, SeatunnelColumnType.STRING),

    BIGINT(new String[]{"bigint"}, SeatunnelColumnType.STRING),

    STR(new String[]{"bigint"}, SeatunnelColumnType.STRING);

    private String[] types;
    private SeatunnelColumnType seatunnelType;


    public SeatunnelColumnType of(String columnType) {
        Optional<MysqlToSeatunnelEnum> optional = Stream.of(MysqlToSeatunnelEnum.values()).filter(item -> ArrayUtil.containsIgnoreCase(item.getTypes(), columnType)).findFirst();
        return optional.orElse(MysqlToSeatunnelEnum.STRING).getSeatunnelType();
    }
}

