package com.airlock.iam.base.infrastructure.transfer.response;

import ch.ergon.restal.jsonapi.Metadata;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotNull;
import java.util.Map;

@JsonTypeName("jsonapi.metadata.validation.error")
@JsonInclude(Include.NON_NULL)
public class ValidationErrorMetadata extends Metadata {
   public static final String DETAIL_KEY = "detail";
   public static final String PARAMETERS_KEY = "parameters";
   public static final String VALIDATION_FAILED_METADATA_TYPE = "jsonapi.metadata.validation.error";
   @NotNull
   @Schema(description = "A detail code specifying the validation error.")
   private final String detail = null;
   @Nullable
   @Schema(description = "Optional key-value pairs providing additional information about the validation error.")
   private final Map<String, Object> parameters = null;

   public void setDetail(String detail) {
      this.addValue("detail", detail);
   }

   public String detail() {
      return (String)this.getValues().get("detail");
   }

   public void setParameters(Map<String, Object> params) {
      if (params != null) {
         this.addValue("parameters", params);
      }
   }

   public Map<String, Object> parameters() {
      return (Map<String, Object>)this.getValues().get("parameters");
   }

   @SuppressFBWarnings(justification = "generated code")
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof ValidationErrorMetadata other)) {
         return false;
      } else if (!other.canEqual(this)) {
         return false;
      } else if (!super.equals(o)) {
         return false;
      } else {
         Object this$detail = this.detail;
         Object other$detail = other.detail;
         if (this$detail == null ? other$detail == null : this$detail.equals(other$detail)) {
            Object this$parameters = this.parameters;
            Object other$parameters = other.parameters;
            return this$parameters == null ? other$parameters == null : this$parameters.equals(other$parameters);
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   protected boolean canEqual(Object other) {
      return other instanceof ValidationErrorMetadata;
   }

   @SuppressFBWarnings(justification = "generated code")
   public int hashCode() {
      int PRIME = 59;
      int result = super.hashCode();
      Object $detail = this.detail;
      result = result * 59 + ($detail == null ? 43 : $detail.hashCode());
      Object $parameters = this.parameters;
      return result * 59 + ($parameters == null ? 43 : $parameters.hashCode());
   }
}
