package com.airlock.iam.authentication.infrastructure.transfer.request;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.HashMap;
import java.util.Map;

public final class UsernamePasswordCheckRequest {
   @NotNull
   @Schema(minLength = 1, maxLength = 500)
   @NotBlank
   @Size(min = 1, max = 500)
   private String username;
   @NotNull
   @Schema(minLength = 1, maxLength = 100000)
   @Size(min = 1, max = 100000)
   private String password;
   @Nullable
   @Schema(description = "Optional set of attributes to be considered by this authentication step.")
   private Map<@Size(max = 1000) String, @Size(max = 10000) String> attributes = new HashMap<>();

   public static UsernamePasswordCheckRequest with(String username, String password) {
      UsernamePasswordCheckRequest request = new UsernamePasswordCheckRequest();
      request.setUsername(username);
      request.setPassword(password);
      return request;
   }

   @SuppressFBWarnings(justification = "generated code")
   public String getUsername() {
      return this.username;
   }

   @SuppressFBWarnings(justification = "generated code")
   public String getPassword() {
      return this.password;
   }

   @Nullable
   @SuppressFBWarnings(justification = "generated code")
   public Map<@Size(max = 1000) String, @Size(max = 10000) String> getAttributes() {
      return this.attributes;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setUsername(String username) {
      this.username = username;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setPassword(String password) {
      this.password = password;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setAttributes(@Nullable Map<@Size(max = 1000) String, @Size(max = 10000) String> attributes) {
      this.attributes = attributes;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof UsernamePasswordCheckRequest other)) {
         return false;
      } else {
         Object this$username = this.username;
         Object other$username = other.username;
         if (this$username == null ? other$username == null : this$username.equals(other$username)) {
            Object this$password = this.password;
            Object other$password = other.password;
            if (this$password == null ? other$password == null : this$password.equals(other$password)) {
               Object this$attributes = this.attributes;
               Object other$attributes = other.attributes;
               return this$attributes == null ? other$attributes == null : this$attributes.equals(other$attributes);
            } else {
               return false;
            }
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      Object $username = this.username;
      result = result * 59 + ($username == null ? 43 : $username.hashCode());
      Object $password = this.password;
      result = result * 59 + ($password == null ? 43 : $password.hashCode());
      Object $attributes = this.attributes;
      return result * 59 + ($attributes == null ? 43 : $attributes.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "UsernamePasswordCheckRequest(username=" + this.getUsername() + ", password=" + this.getPassword() + ", attributes=" + this.getAttributes() + ")";
   }
}
