package com.xhpc.evcs.dto;

import com.fasterxml.jackson.annotation.*;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;


@JsonPropertyOrder({
        "ConnectorID",
        "Status"
})
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
        setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
@Getter
@Setter
public class ConnectorStatusInfo {

    public final static int OFF_LINE = 0;//离网
    public final static int FREE = 1;//空闲
    public final static int CONNECTED = 2;//占用（未充电)
    public final static int CHARGING = 3;//占用（充电中）
    public final static int BOOKED = 4;//占用（预约锁定)
    public final static int ERROR = 255;//故障

    @JsonProperty("ConnectorID")
    private String connectorID;
    @JsonIgnore()
    private String operatorID;
    @JsonProperty("Status")
    private Integer status;

    @JsonIgnore
    private Map<String, Object> additionalProperties = new HashMap<String, Object>();

    @JsonAnyGetter
    public Map<String, Object> getAdditionalProperties() {

        return this.additionalProperties;
    }

    @JsonAnySetter
    public void setAdditionalProperty(String name, Object value) {

        this.additionalProperties.put(name, value);
    }

    @Override
    public String toString() {

        return new ToStringBuilder(this)
                .append("connectorID", connectorID)
                .append("operatorID", operatorID)
                .append("status", status)
                .append("additionalProperties", additionalProperties)
                .toString();
    }

    @Override
    public boolean equals(Object o) {

        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ConnectorStatusInfo that = (ConnectorStatusInfo) o;
        return connectorID.equals(that.connectorID) && operatorID.equals(that.operatorID);
    }

    @Override
    public int hashCode() {

        return Objects.hash(connectorID, operatorID);
    }

}
