package com.usky.rule.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.usky.rule.vo.validator.GroupInsert;
import com.usky.rule.vo.validator.GroupUpdate;
import java.math.BigDecimal;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.PositiveOrZero;

public class DataPointVO {
    private @NotNull(
            groups = {GroupInsert.class, GroupUpdate.class},
            message = "时间不能为空"
    ) @Pattern(
            groups = {GroupInsert.class, GroupUpdate.class},
            regexp = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)\\s+([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$",
            message = "时间格式错误"
    ) String time;
    @JsonSerialize(
            using = ToStringSerializer.class
    )
    private @PositiveOrZero(
            groups = {GroupInsert.class, GroupUpdate.class},
            message = "值不能小于0"
    ) BigDecimal value;
    private @NotNull String sampleTime;
    @JsonIgnore
    private BigDecimal previousValue;
    @JsonIgnore
    private BigDecimal nextValue;
    @JsonIgnore
    private BigDecimal oldValue;
    @JsonIgnore
    private DataPointVO previousVO;
    @JsonIgnore
    private DataPointVO nextVO;
    @JsonIgnore
    private String realTime;

    public DataPointVO(String time, BigDecimal value) {
        this.time = time;
        this.value = value;
    }

    public DataPointVO(String time, BigDecimal old, BigDecimal value) {
        this.time = time;
        this.oldValue = old;
        this.value = value;
    }

    public @NotNull(
            groups = {GroupInsert.class, GroupUpdate.class},
            message = "时间不能为空"
    ) String getTime() {
        return this.time;
    }

    public BigDecimal getValue() {
        return this.value;
    }

    public @NotNull String getSampleTime() {
        return this.sampleTime;
    }

    public BigDecimal getPreviousValue() {
        return this.previousValue;
    }

    public BigDecimal getNextValue() {
        return this.nextValue;
    }

    public BigDecimal getOldValue() {
        return this.oldValue;
    }

    public DataPointVO getPreviousVO() {
        return this.previousVO;
    }

    public DataPointVO getNextVO() {
        return this.nextVO;
    }

    public String getRealTime() {
        return this.realTime;
    }

    public void setTime(final @NotNull(
            groups = {GroupInsert.class, GroupUpdate.class},
            message = "时间不能为空"
    ) String time) {
        this.time = time;
    }

    public void setValue(final BigDecimal value) {
        this.value = value;
    }

    public void setSampleTime(final @NotNull String sampleTime) {
        this.sampleTime = sampleTime;
    }

    @JsonIgnore
    public void setPreviousValue(final BigDecimal previousValue) {
        this.previousValue = previousValue;
    }

    @JsonIgnore
    public void setNextValue(final BigDecimal nextValue) {
        this.nextValue = nextValue;
    }

    @JsonIgnore
    public void setOldValue(final BigDecimal oldValue) {
        this.oldValue = oldValue;
    }

    @JsonIgnore
    public void setPreviousVO(final DataPointVO previousVO) {
        this.previousVO = previousVO;
    }

    @JsonIgnore
    public void setNextVO(final DataPointVO nextVO) {
        this.nextVO = nextVO;
    }

    @JsonIgnore
    public void setRealTime(final String realTime) {
        this.realTime = realTime;
    }

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

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

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

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

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

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

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

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

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

                return true;
            }
        }
    }

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

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        Object $time = this.getTime();
        result = result * 59 + ($time == null ? 43 : $time.hashCode());
        Object $value = this.getValue();
        result = result * 59 + ($value == null ? 43 : $value.hashCode());
        Object $sampleTime = this.getSampleTime();
        result = result * 59 + ($sampleTime == null ? 43 : $sampleTime.hashCode());
        Object $previousValue = this.getPreviousValue();
        result = result * 59 + ($previousValue == null ? 43 : $previousValue.hashCode());
        Object $nextValue = this.getNextValue();
        result = result * 59 + ($nextValue == null ? 43 : $nextValue.hashCode());
        Object $oldValue = this.getOldValue();
        result = result * 59 + ($oldValue == null ? 43 : $oldValue.hashCode());
        Object $previousVO = this.getPreviousVO();
        result = result * 59 + ($previousVO == null ? 43 : $previousVO.hashCode());
        Object $nextVO = this.getNextVO();
        result = result * 59 + ($nextVO == null ? 43 : $nextVO.hashCode());
        Object $realTime = this.getRealTime();
        result = result * 59 + ($realTime == null ? 43 : $realTime.hashCode());
        return result;
    }

    public String toString() {
        return "DataPointVO(time=" + this.getTime() + ", value=" + this.getValue() + ", sampleTime=" + this.getSampleTime() + ", previousValue=" + this.getPreviousValue() + ", nextValue=" + this.getNextValue() + ", oldValue=" + this.getOldValue() + ", previousVO=" + this.getPreviousVO() + ", nextVO=" + this.getNextVO() + ", realTime=" + this.getRealTime() + ")";
    }

    public DataPointVO() {
    }
}
