package org.ts.ddcs.DataItemTemplate;

import org.ts.ddcs.DataTemplate.ItemTemplateSet;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("all")
public abstract class DataItemTemplate implements DataItemTemplateInterface {
    protected String feture;
    protected String sqlColumn;
    protected String tableName;
    protected String desc;
    protected boolean macth = false;
    protected String name;
    protected String varcharValue;
    protected BigDecimal bigDecimalValue;
    protected Map<String, Object> datas;
    protected byte[] valueBuff = new byte[0];
    protected boolean outlierData = false;

    @Override
    public void Init(ItemTemplateSet template) {
        this.feture = template.getFeature();
        this.name = template.getDataTemplate();
        this.desc = template.getDesc();
        this.sqlColumn = template.getColumn();
        this.tableName = template.getTable();
        datas = new HashMap<>();
    }

    @Override
    public String GetFeture() {
        return this.feture;
    }

    @Override
    public Map<String, Object> GetDatas() {
        return this.datas;
    }

    @Override
    public String toString() {
        if (null != bigDecimalValue) {
            return bigDecimalValue.toPlainString();
        }
        if (null != varcharValue) {
            return varcharValue;
        }
        return null;
    }

    @Override
    public boolean OutlierData() {
        return this.outlierData;
    }

    @Override
    public String GetName() {
        return this.name;
    }

    @Override
    public BigDecimal GetDecimal() {
        return this.bigDecimalValue;
    }

    @Override
    public String GetVarchar() {
        return this.varcharValue;
    }

    @Override
    public void SetVarchar(String value) {
        this.varcharValue = value;
    }

    @Override
    public byte[] GetByteArray() {
        return valueBuff;
    }

    @Override
    public byte[] Stream(byte[] data) {
        return data;
    }

    @Override
    public boolean Macth() {
        return this.macth;
    }

    @Override
    public String GetColumnName() {
        return this.sqlColumn;
    }

    @Override
    public String GetTableName() {
        return this.tableName;
    }

    @Override
    public void SetEntity(Object entity) {
    }

    @Override
    public String GetDesc() {
        return this.desc;
    }
}
