package com.sdtool.common.entity.base;

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

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

/**
 * Created by jlutt on 2020-08-11
 *
 * @author jlutt
 */
public class ProcessMultiEntityItem<T extends BaseEntity> extends BaseEntity {

    private List<T> inputItemList;

    private BusinessOperation operation;

    private ERPTokenUser currentUser;

    private String dataSourceId;

    private String inputString;

    private long supplierCode;

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

    public ProcessMultiEntityItem() {
    }

    public ProcessMultiEntityItem<T> addConvert(String name, JsonConvert jsonConvert) {
        this.jsonConvertMap.put(name, jsonConvert);
        return this;
    }

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

    public List<T> getInputItemList() {
        return inputItemList;
    }

    public void setInputItemList(List<T> inputItemList) {
        this.inputItemList = inputItemList;
    }

    public BusinessOperation getOperation() {
        return operation;
    }

    public void setOperation(BusinessOperation operation) {
        this.operation = operation;
    }

    public String getDataSourceId() {
        return dataSourceId;
    }

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

    public String getInputString() {
        return inputString;
    }

    public void setInputString(String inputString) {
        this.inputString = inputString;
    }

    public long getSupplierCode() {
        return supplierCode;
    }

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

    public ERPTokenUser getCurrentUser() {
        return currentUser;
    }

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



    public static final class ProcessMultiEntityItemBuilder<T extends BaseEntity> {
        private List<T> inputItemList;
        private BusinessOperation operation;
        private ERPTokenUser currentUser;
        private String dataSourceId;
        private String inputString;
        private long supplierCode;
        private long createBy;
        private Date createTime;
        private long createTimeLong;
        private long updateBy;
        private Date updateTime;
        private long updateTimeLong;

        private ProcessMultiEntityItemBuilder() {
        }

        public static <T extends BaseEntity> ProcessMultiEntityItemBuilder<T> aProcessMultiEntityItem() {
            return new ProcessMultiEntityItemBuilder<>();
        }
      //  public static <T extends BaseEntity> ProcessEntityItem.Builder<T> newBuilder() {
      //      return new ProcessEntityItem.Builder<>();
      //  }

        public ProcessMultiEntityItemBuilder<T> inputItemList(List<T> inputItemList) {
            this.inputItemList = inputItemList;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> operation(BusinessOperation operation) {
            this.operation = operation;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> currentUser(ERPTokenUser currentUser) {
            this.currentUser = currentUser;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> dataSourceId(String dataSourceId) {
            this.dataSourceId = dataSourceId;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> inputString(String inputString) {
            this.inputString = inputString;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> supplierCode(long supplierCode) {
            this.supplierCode = supplierCode;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> createBy(long createBy) {
            this.createBy = createBy;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> createTime(Date createTime) {
            this.createTime = createTime;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> createTimeLong(long createTimeLong) {
            this.createTimeLong = createTimeLong;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> updateBy(long updateBy) {
            this.updateBy = updateBy;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> updateTime(Date updateTime) {
            this.updateTime = updateTime;
            return this;
        }

        public ProcessMultiEntityItemBuilder<T> updateTimeLong(long updateTimeLong) {
            this.updateTimeLong = updateTimeLong;
            return this;
        }


        public ProcessMultiEntityItem<T> build() {
            ProcessMultiEntityItem<T> processMultiEntityItem = new ProcessMultiEntityItem<>();
            processMultiEntityItem.setInputItemList(inputItemList);
            processMultiEntityItem.setOperation(operation);
            processMultiEntityItem.setCurrentUser(currentUser);
            processMultiEntityItem.setDataSourceId(dataSourceId);
            processMultiEntityItem.setInputString(inputString);
            processMultiEntityItem.setSupplierCode(supplierCode);
            processMultiEntityItem.setCreateBy(createBy);
            processMultiEntityItem.setCreateTime(createTime);
            processMultiEntityItem.setCreateTimeLong(createTimeLong);
            processMultiEntityItem.setUpdateBy(updateBy);
            processMultiEntityItem.setUpdateTime(updateTime);
            processMultiEntityItem.setUpdateTimeLong(updateTimeLong);
            return processMultiEntityItem;
        }
    }
}
