package com.oguerreiro.resilient.service.dto;

import java.math.BigDecimal;

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

/**
 * A DTO for the {@link com.oguerreiro.resilient.domain.Unit} entity.
 */
@Schema(description = "Unit")
public class UnitDTO extends AbstractResilientDTO<Long> {
  private static final long serialVersionUID = 1L;

  @NotNull
  @Schema(description = "Required code to use in integrations", requiredMode = Schema.RequiredMode.REQUIRED)
  private String code;

  @NotNull
  @Schema(description = "Math symbol that is usually used as sufix for this unit. Eg. 'm3' for square metters.", requiredMode = Schema.RequiredMode.REQUIRED)
  private String symbol;

  @NotNull
  @Schema(description = "Math name for this unit. Eg. 'Square metters'.", requiredMode = Schema.RequiredMode.REQUIRED)
  private String name;

  private String description;

  @NotNull
  @Schema(description = "The convertion rate (CR), relative to the base unit.\nThis values awnsers the question: When the base unit is 1 (one), whats the value of this unit measure ?\nEx: How many Ml (miligrams) 1Kg has? 1000\nThe formula to convert between any value unit the scale is:\n<Value>*CR(target unit)/CR(source unit)", requiredMode = Schema.RequiredMode.REQUIRED)
  private BigDecimal convertionRate;

  private UnitTypeDTO unitType;

  public String getCode() {
    return code;
  }

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

  public String getSymbol() {
    return symbol;
  }

  public void setSymbol(String symbol) {
    this.symbol = symbol;
  }

  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 BigDecimal getConvertionRate() {
    return convertionRate;
  }

  public void setConvertionRate(BigDecimal convertionRate) {
    this.convertionRate = convertionRate;
  }

  public UnitTypeDTO getUnitType() {
    return unitType;
  }

  public void setUnitType(UnitTypeDTO unitType) {
    this.unitType = unitType;
  }

  //@formatter:off
  @Override
  public String toString() {        
    return "UnitDTO{" +
              "id=" + getId() +
              ", code='" + getCode() + "'" +
              ", symbol='" + getSymbol() + "'" +
              ", name='" + getName() + "'" +
              ", description='" + getDescription() + "'" +
              ", convertionRate=" + getConvertionRate() +
              ", unitType=" + getUnitType() +
              ", version=" + getVersion() +
           "}";
  }
  //@formatter:off
}
