package com.tmerclub.cloud.search.canal.common;

/**
 * @author throwable
 * @version v1
 * @description binlog事件类型
 * @since 2020/9/20 17:19
 */
public enum BinLogEventType {

    /**
     * 查询
     */
    QUERY("QUERY", "查询"),

    /**
     * 新增
     */
    INSERT("INSERT", "新增"),

    /**
     * 更新
     */
    UPDATE("UPDATE", "更新"),

    /**
     * 删除
     */
    DELETE("DELETE", "删除"),

    /**
     * 列修改操作
     */
    ALTER("ALTER", "列修改操作"),

    /**
     * 表创建
     */
    CREATE("CREATE", "表创建"),

    /**
     * 未知
     */
    UNKNOWN("UNKNOWN", "未知"),

    ;

    private final String type;
    private final String description;

    BinLogEventType(String type, String description) {
        this.type = type;
        this.description = description;
    }

    public String getType() {
        return type;
    }

    public String getDescription() {
        return description;
    }

    public static BinLogEventType fromType(String type) {
        for (BinLogEventType binLogType : values()) {
            if (binLogType.getType().equals(type)) {
                return binLogType;
            }
        }
        return UNKNOWN;
    }
}
