package com.sdtool.common.entity.base;

import com.sdtool.common.entity.site.ERPTokenUser;
import com.sweetfish.convert.json.JsonConvert;
import org.rex.RMap;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by jlutt on 2020-08-14
 *
 * @author jlutt
 */
@SuppressWarnings("rawtypes")
public class ProcessMapItem extends BaseEntity {

    private RMap itemData;

    private ERPTokenUser currentUser;

    private String dataSourceId;

    private long supplierCode;

    private final Map<String, JsonConvert> jsonConvertMap = new HashMap<>();

    public ProcessMapItem() {
    }

    public ProcessMapItem addConvert(String name, JsonConvert jsonConvert) {
        this.jsonConvertMap.put(name, jsonConvert);
        return this;
    }

    public JsonConvert getConvert(String name) {
        return jsonConvertMap.get(name);
    }

    private ProcessMapItem(Builder builder) {
        setCreateBy(builder.createBy);
        setCreateTime(builder.createTime);
        setCreateTimeLong(builder.createTimeLong);
        setUpdateBy(builder.updateBy);
        setUpdateTime(builder.updateTime);
        setUpdateTimeLong(builder.updateTimeLong);
        setItemData(builder.itemData);
        setCurrentUser(builder.currentUser);
        setDataSourceId(builder.dataSourceId);
        setSupplierCode(builder.supplierCode);
    }

    public static Builder newBuilder() {
        return new Builder();
    }


    public RMap getItemData() {
        return itemData;
    }

    public void setItemData(RMap itemData) {
        this.itemData = itemData;
    }

    public ERPTokenUser getCurrentUser() {
        return currentUser;
    }

    public void setCurrentUser(ERPTokenUser currentUser) {
        this.currentUser = currentUser;
    }

    public String getDataSourceId() {
        return dataSourceId;
    }

    public void setDataSourceId(String dataSourceId) {
        this.dataSourceId = dataSourceId;
    }

    public long getSupplierCode() {
        return supplierCode;
    }

    public void setSupplierCode(long supplierCode) {
        this.supplierCode = supplierCode;
    }

    public static final class Builder {
        private long createBy;
        private Date createTime;
        private long createTimeLong;
        private long updateBy;
        private Date updateTime;
        private long updateTimeLong;
        private RMap itemData;
        private ERPTokenUser currentUser;
        private String dataSourceId;
        private long supplierCode;

        private Builder() {
        }

        public Builder createBy(long val) {
            createBy = val;
            return this;
        }

        public Builder createTime(Date val) {
            createTime = val;
            return this;
        }

        public Builder createTimeLong(long val) {
            createTimeLong = val;
            return this;
        }

        public Builder updateBy(long val) {
            updateBy = val;
            return this;
        }

        public Builder updateTime(Date val) {
            updateTime = val;
            return this;
        }

        public Builder updateTimeLong(long val) {
            updateTimeLong = val;
            return this;
        }

        public Builder itemData(RMap val) {
            itemData = val;
            return this;
        }

        public Builder currentUser(ERPTokenUser val) {
            currentUser = val;
            return this;
        }

        public Builder dataSourceId(String val) {
            dataSourceId = val;
            return this;
        }

        public Builder supplierCode(long val) {
            supplierCode = val;
            return this;
        }

        public ProcessMapItem build() {
            return new ProcessMapItem(this);
        }
    }
}
