package com.tmerclub.cloud.search.canal.support.parser.converter;

import java.sql.SQLType;

/**
 * @author throwable
 * @version v1
 * @description
 * @since 2020/9/22 0:55
 */
@SuppressWarnings("rawtypes")
public class CanalFieldConvertInput {

    private Class<?> fieldKlass;
    private Class<? extends BaseCanalFieldConverter> converterKlass;
    private SQLType sqlType;

    public CanalFieldConvertInput() {

    }

    public CanalFieldConvertInput(Class<?> fieldKlass, Class<? extends BaseCanalFieldConverter> converterKlass, SQLType sqlType) {
        this.fieldKlass = fieldKlass;
        this.converterKlass = converterKlass;
        this.sqlType = sqlType;
    }

    public static CanalFieldConvertInputBuild builder() {
        return new CanalFieldConvertInputBuild();
    }

    public static class CanalFieldConvertInputBuild {
        private Class<?> fieldKlass;
        private Class<? extends BaseCanalFieldConverter> converterKlass;
        private SQLType sqlType;

        public CanalFieldConvertInputBuild fieldKlass(Class<?> fieldKlass) {
            this.fieldKlass = fieldKlass;
            return this;
        }

        public CanalFieldConvertInputBuild converterKlass(Class<? extends BaseCanalFieldConverter> converterKlass) {
            this.converterKlass = converterKlass;
            return this;
        }

        public CanalFieldConvertInputBuild sqlType(SQLType sqlType) {
            this.sqlType = sqlType;
            return this;
        }

        public CanalFieldConvertInput build() {
            return new CanalFieldConvertInput(fieldKlass, converterKlass, sqlType);
        }
    }

    public Class<?> getFieldKlass() {
        return fieldKlass;
    }

    public void setFieldKlass(Class<?> fieldKlass) {
        this.fieldKlass = fieldKlass;
    }

    public Class<? extends BaseCanalFieldConverter> getConverterKlass() {
        return converterKlass;
    }

    public void setConverterKlass(Class<? extends BaseCanalFieldConverter> converterKlass) {
        this.converterKlass = converterKlass;
    }

    public SQLType getSqlType() {
        return sqlType;
    }

    public void setSqlType(SQLType sqlType) {
        this.sqlType = sqlType;
    }

    @Override
    public String toString() {
        return "CanalFieldConvertInput{" +
                "fieldKlass=" + fieldKlass +
                ", converterKlass=" + converterKlass +
                ", sqlType=" + sqlType +
                '}';
    }
}
