package io.delphiplatform.api.v3.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import java.util.Objects;

import javax.validation.constraints.NotNull;

import io.delphiplatform.api.v3.rdb.entity.LabelEntity;

/**
 * Label
 */
@JsonPropertyOrder(alphabetic = true)
public class Label {

    @JsonProperty("name")
    private String name;

    @JsonProperty("label_id")
    private String labelId;

    public static Label from(LabelEntity label) {
        if (label == null) {
            return null;
        }
        return new Label()
            .name(label.getName())
            .labelId(label.getLabelId());
    }

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

    /**
     * Get name
     *
     * @return name
     */
    @NotNull
    public String getName() {
        return name;
    }

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

    public Label labelId(String labelId) {
        this.labelId = labelId;
        return this;
    }

    /**
     * Primary key identifier for Label
     *
     * @return labelId
     */
    @NotNull
    public String getLabelId() {
        return labelId;
    }

    public void setLabelId(String labelId) {
        this.labelId = labelId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Label label = (Label) o;
        return Objects.equals(this.name, label.name) &&
            Objects.equals(this.labelId, label.labelId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, labelId);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class Label {\n");

        sb.append("    name: ").append(toIndentedString(name)).append("\n");
        sb.append("    labelId: ").append(toIndentedString(labelId)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }
}
