package com.usky.rule.vo;

import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.usky.rule.util.JsonToStringDeserializer;
import com.usky.rule.vo.validator.GroupInsert;
import com.usky.rule.vo.validator.GroupUpdate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@ApiModel
public class RuleEngineDTO implements Serializable {
    private static final long serialVersionUID = -80869839545181400L;
    @ApiModelProperty("自增ID")
    private @NotNull(
            groups = {GroupUpdate.class},
            message = "id不能为空"
    ) Long id;
    @ApiModelProperty("项目ID")
    private Long projectId;
    @ApiModelProperty("名称")
    private @NotEmpty(
            groups = {GroupUpdate.class, GroupInsert.class},
            message = "名称不能为空"
    ) String name;
    @ApiModelProperty("空间ID")
    private @NotNull(
            groups = {GroupInsert.class},
            message = "空间不能为空"
    ) Long spaceId;
    @ApiModelProperty("规则状态 1：启用 0：停用")
    private Integer status;
    @ApiModelProperty("规则描述")
    private String descr;
    @ApiModelProperty("规则详情")
    @JsonDeserialize(
            using = JsonToStringDeserializer.class
    )
    @JsonRawValue
    private String detail;

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

    public @NotNull(
            groups = {GroupUpdate.class},
            message = "id不能为空"
    ) Long getId() {
        return this.id;
    }

    public Long getProjectId() {
        return this.projectId;
    }

    public String getName() {
        return this.name;
    }

    public @NotNull(
            groups = {GroupInsert.class},
            message = "空间不能为空"
    ) Long getSpaceId() {
        return this.spaceId;
    }

    public Integer getStatus() {
        return this.status;
    }

    public String getDescr() {
        return this.descr;
    }

    public String getDetail() {
        return this.detail;
    }

    public void setId(final @NotNull(
            groups = {GroupUpdate.class},
            message = "id不能为空"
    ) Long id) {
        this.id = id;
    }

    public void setProjectId(final Long projectId) {
        this.projectId = projectId;
    }

    public void setName(final String name) {
        this.name = name;
    }

    public void setSpaceId(final @NotNull(
            groups = {GroupInsert.class},
            message = "空间不能为空"
    ) Long spaceId) {
        this.spaceId = spaceId;
    }

    public void setStatus(final Integer status) {
        this.status = status;
    }

    public void setDescr(final String descr) {
        this.descr = descr;
    }

    @JsonDeserialize(
            using = JsonToStringDeserializer.class
    )
    public void setDetail(final String detail) {
        this.detail = detail;
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof RuleEngineDTO)) {
            return false;
        } else {
            RuleEngineDTO other = (RuleEngineDTO)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$id = this.getId();
                Object other$id = other.getId();
                if (this$id == null) {
                    if (other$id != null) {
                        return false;
                    }
                } else if (!this$id.equals(other$id)) {
                    return false;
                }

                Object this$projectId = this.getProjectId();
                Object other$projectId = other.getProjectId();
                if (this$projectId == null) {
                    if (other$projectId != null) {
                        return false;
                    }
                } else if (!this$projectId.equals(other$projectId)) {
                    return false;
                }

                Object this$spaceId = this.getSpaceId();
                Object other$spaceId = other.getSpaceId();
                if (this$spaceId == null) {
                    if (other$spaceId != null) {
                        return false;
                    }
                } else if (!this$spaceId.equals(other$spaceId)) {
                    return false;
                }

                Object this$status = this.getStatus();
                Object other$status = other.getStatus();
                if (this$status == null) {
                    if (other$status != null) {
                        return false;
                    }
                } else if (!this$status.equals(other$status)) {
                    return false;
                }

                Object this$name = this.getName();
                Object other$name = other.getName();
                if (this$name == null) {
                    if (other$name != null) {
                        return false;
                    }
                } else if (!this$name.equals(other$name)) {
                    return false;
                }

                Object this$descr = this.getDescr();
                Object other$descr = other.getDescr();
                if (this$descr == null) {
                    if (other$descr != null) {
                        return false;
                    }
                } else if (!this$descr.equals(other$descr)) {
                    return false;
                }

                Object this$detail = this.getDetail();
                Object other$detail = other.getDetail();
                if (this$detail == null) {
                    if (other$detail != null) {
                        return false;
                    }
                } else if (!this$detail.equals(other$detail)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof RuleEngineDTO;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        Object $id = this.getId();
        result = result * 59 + ($id == null ? 43 : $id.hashCode());
        Object $projectId = this.getProjectId();
        result = result * 59 + ($projectId == null ? 43 : $projectId.hashCode());
        Object $spaceId = this.getSpaceId();
        result = result * 59 + ($spaceId == null ? 43 : $spaceId.hashCode());
        Object $status = this.getStatus();
        result = result * 59 + ($status == null ? 43 : $status.hashCode());
        Object $name = this.getName();
        result = result * 59 + ($name == null ? 43 : $name.hashCode());
        Object $descr = this.getDescr();
        result = result * 59 + ($descr == null ? 43 : $descr.hashCode());
        Object $detail = this.getDetail();
        result = result * 59 + ($detail == null ? 43 : $detail.hashCode());
        return result;
    }

    public String toString() {
        return "RuleEngineDTO(id=" + this.getId() + ", projectId=" + this.getProjectId() + ", name=" + this.getName() + ", spaceId=" + this.getSpaceId() + ", status=" + this.getStatus() + ", descr=" + this.getDescr() + ", detail=" + this.getDetail() + ")";
    }

    public RuleEngineDTO(final @NotNull(
            groups = {GroupUpdate.class},
            message = "id不能为空"
    ) Long id, final Long projectId, final String name, final @NotNull(
            groups = {GroupInsert.class},
            message = "空间不能为空"
    ) Long spaceId, final Integer status, final String descr, final String detail) {
        this.id = id;
        this.projectId = projectId;
        this.name = name;
        this.spaceId = spaceId;
        this.status = status;
        this.descr = descr;
        this.detail = detail;
    }

    public RuleEngineDTO() {
    }

    public static class RuleEngineDTOBuilder {
        private Long id;
        private Long projectId;
        private String name;
        private Long spaceId;
        private Integer status;
        private String descr;
        private String detail;

        RuleEngineDTOBuilder() {
        }

        public RuleEngineDTOBuilder id(final @NotNull(
                groups = {GroupUpdate.class},
                message = "id不能为空"
        ) Long id) {
            this.id = id;
            return this;
        }

        public RuleEngineDTOBuilder projectId(final Long projectId) {
            this.projectId = projectId;
            return this;
        }

        public RuleEngineDTOBuilder name(final String name) {
            this.name = name;
            return this;
        }

        public RuleEngineDTOBuilder spaceId(final @NotNull(
                groups = {GroupInsert.class},
                message = "空间不能为空"
        ) Long spaceId) {
            this.spaceId = spaceId;
            return this;
        }

        public RuleEngineDTOBuilder status(final Integer status) {
            this.status = status;
            return this;
        }

        public RuleEngineDTOBuilder descr(final String descr) {
            this.descr = descr;
            return this;
        }

        @JsonDeserialize(
                using = JsonToStringDeserializer.class
        )
        public RuleEngineDTOBuilder detail(final String detail) {
            this.detail = detail;
            return this;
        }

        public RuleEngineDTO build() {
            return new RuleEngineDTO(this.id, this.projectId, this.name, this.spaceId, this.status, this.descr, this.detail);
        }

        public String toString() {
            return "RuleEngineDTO.RuleEngineDTOBuilder(id=" + this.id + ", projectId=" + this.projectId + ", name=" + this.name + ", spaceId=" + this.spaceId + ", status=" + this.status + ", descr=" + this.descr + ", detail=" + this.detail + ")";
        }
    }
}
