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

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonTypeName;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Size;
import java.util.HashMap;
import java.util.Map;

@JsonTypeName("oauth2-session-custom-attributes")
@Schema(ref = "#/components/schemas/OAuth2SessionUpdateRequestOverride")
public final class OAuth2SessionUpdateRequest {
   private final Map<String, String> customAttributes = new HashMap<>();

   @JsonAnyGetter
   public Map<@Size(min = 1, max = 1000) String, @Size(min = 1, max = 10000) String> getCustomAttributes() {
      return this.customAttributes;
   }

   @JsonAnySetter
   public void addCustomAttribute(String name, String value) {
      this.customAttributes.put(name, value);
   }

   public void setCustomAttributes(Map<String, String> attributes) {
      this.customAttributes.clear();
      this.customAttributes.putAll(attributes);
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "OAuth2SessionUpdateRequest(customAttributes=" + this.getCustomAttributes() + ")";
   }
}
