package de.avatic.lcc.model.db.nodes;

import org.jetbrains.annotations.Debug.Renderer;
import jakarta.validation.constraints.*;
import org.springframework.validation.annotation.Validated;

import java.math.BigDecimal;
import java.time.OffsetDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Renderer(text = "getDebugText()")
@Validated
public class Node {

    private Integer id;

    @NotNull
    @Size(max = 255)
    private String name;

    @NotNull
    @Size(max = 500)
    private String address;

    @Size(max = 32)
    private String externalMappingId;

    @NotNull
    private Boolean predecessorRequired;

    private Boolean isDestination;

    private Boolean isSource;

    private Boolean isIntermediate;

    @Digits(integer = 7, fraction = 4)
    @DecimalMin("-90.0000")
    @DecimalMax("90.0000")
    private BigDecimal geoLat;

    @Digits(integer = 7, fraction = 4)
    @DecimalMin("-180.0000")
    @DecimalMax("180.0000")
    private BigDecimal geoLng;

    private OffsetDateTime updatedAt;

    private Boolean isDeprecated;

    private Integer countryId;

    private List<Map<Integer, Integer>> nodePredecessors;

    private Collection<Integer> outboundCountries;

    private boolean isUserNode = false;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

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

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getExternalMappingId() {
        return externalMappingId;
    }

    public void setExternalMappingId(String externalMappingId) {
        this.externalMappingId = externalMappingId;
    }

    public Boolean getPredecessorRequired() {
        return predecessorRequired;
    }

    public void setPredecessorRequired(Boolean predecessorRequired) {
        this.predecessorRequired = predecessorRequired;
    }

    public Boolean getDestination() {
        return isDestination;
    }

    public void setDestination(Boolean destination) {
        isDestination = destination;
    }

    public Boolean getSource() {
        return isSource;
    }

    public void setSource(Boolean source) {
        isSource = source;
    }

    public Boolean getIntermediate() {
        return isIntermediate;
    }

    public void setIntermediate(Boolean intermediate) {
        isIntermediate = intermediate;
    }

    public BigDecimal getGeoLat() {
        return geoLat;
    }

    public void setGeoLat(BigDecimal geoLat) {
        this.geoLat = geoLat;
    }

    public BigDecimal getGeoLng() {
        return geoLng;
    }

    public void setGeoLng(BigDecimal geoLng) {
        this.geoLng = geoLng;
    }

    public OffsetDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(OffsetDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Boolean getDeprecated() {
        return isDeprecated;
    }

    public void setDeprecated(Boolean deprecated) {
        isDeprecated = deprecated;
    }

    public Integer getCountryId() {
        return countryId;
    }

    public void setCountryId(Integer countryId) {
        this.countryId = countryId;
    }

    public List<Map<Integer, Integer>>  getNodePredecessors() {
        return nodePredecessors;
    }

    public void setNodePredecessors(List<Map<Integer, Integer>> nodePredecessors) {
        this.nodePredecessors = nodePredecessors;
    }

    public Collection<Integer> getOutboundCountries() {
        return outboundCountries;
    }

    public void setOutboundCountries(Collection<Integer> outboundCountries) {
        this.outboundCountries = outboundCountries;
    }

    public boolean isUserNode() {
        return isUserNode;
    }

    public void setUserNode(boolean userNode) {
        isUserNode = userNode;
    }

    public String getDebugText() {
        return externalMappingId == null ? "\uD83D\uDC64" + name : externalMappingId;
    }

    public String toString() {
        return getDebugText();
    }
}
