package com.oguerreiro.resilient.service.dto;

import java.util.HashSet;
import java.util.Set;

import com.oguerreiro.resilient.domain.enumeration.MetadataType;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * A DTO for the {@link com.oguerreiro.resilient.domain.MetadataProperty} entity.
 */
@Schema(description = "Metadata Property\nConfiguration of a metadata property. Defines its type and a description of its usage.")
public class MetadataPropertyDTO extends AbstractResilientDTO<Long> {
  private static final long serialVersionUID = 1L;

  @NotNull
  @Size(min = 3)
  private String code;

  @NotNull
  private String name;

  private String description;

  private Boolean mandatory;

  @NotNull
  private MetadataType metadataType;

  @Schema(description = "Regex pattern for validation (optional). Only applies when the value is not empty.")
  private String pattern;

  @Schema(description = "Record version for concurrency control.")
  private Integer version;

  private Set<OrganizationTypeDTO> organizationTypes = new HashSet<>();

  public String getCode() {
    return code;
  }

  public void setCode(String code) {
    this.code = code;
  }

  public String getName() {
    return name;
  }

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

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public Boolean getMandatory() {
    return mandatory;
  }

  public void setMandatory(Boolean mandatory) {
    this.mandatory = mandatory;
  }

  public MetadataType getMetadataType() {
    return metadataType;
  }

  public void setMetadataType(MetadataType metadataType) {
    this.metadataType = metadataType;
  }

  public String getPattern() {
    return pattern;
  }

  public void setPattern(String pattern) {
    this.pattern = pattern;
  }

  public Set<OrganizationTypeDTO> getOrganizationTypes() {
    return organizationTypes;
  }

  public void setOrganizationTypes(Set<OrganizationTypeDTO> organizationTypes) {
    this.organizationTypes = organizationTypes;
  }

  //@formatter:off
  @Override
  public String toString() {
      return "MetadataPropertyDTO{" +
                "id=" + getId() +
                ", code='" + getCode() + "'" +
                ", name='" + getName() + "'" +
                ", description='" + getDescription() + "'" +
                ", mandatory='" + getMandatory() + "'" +
                ", metadataType='" + getMetadataType() + "'" +
                ", pattern='" + getPattern() + "'" +
                ", organizationTypes=" + getOrganizationTypes() +
                ", version=" + getVersion() +
             "}";
  }
  //@formatter:on
}
