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

import com.fasterxml.jackson.annotation.JsonTypeName;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotNull;
import java.time.Instant;
import java.util.List;

@JsonTypeName("authentication.oauth2.consent.local")
public class OAuth2LocalConsentAttributeData {
   static final String OAUTH2_LOCAL_CONSENT_TYPE = "authentication.oauth2.consent.local";
   @NotNull
   @Schema(description = "The name of the client requesting the authorization.")
   private String clientName;
   @ArraySchema(arraySchema = @Schema(description = "The scopes that can be granted."))
   @NotNull
   private List<OAuth2LocalConsentAttributeData.ScopeAttributeData> grantableScopes;

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

   @SuppressFBWarnings(justification = "generated code")
   public List<OAuth2LocalConsentAttributeData.ScopeAttributeData> getGrantableScopes() {
      return this.grantableScopes;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public void setGrantableScopes(List<OAuth2LocalConsentAttributeData.ScopeAttributeData> grantableScopes) {
      this.grantableScopes = grantableScopes;
   }

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

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "OAuth2LocalConsentAttributeData(clientName=" + this.getClientName() + ", grantableScopes=" + this.getGrantableScopes() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2LocalConsentAttributeData(String clientName, List<OAuth2LocalConsentAttributeData.ScopeAttributeData> grantableScopes) {
      this.clientName = clientName;
      this.grantableScopes = grantableScopes;
   }

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2LocalConsentAttributeData() {
   }

   public static class ScopeAttributeData {
      @NotNull
      @Schema(description = "The granted scope (technical name).")
      private String scope;
      @Nullable
      @Schema(description = "A human-readable version of this scope.")
      private String translatedScope;
      @Schema(description = "True if scope was granted in a previous consent.")
      private boolean granted;
      @Nullable
      @Schema(description = "Timestamp of when the scope was granted or denied. If a scope was never granted or denied this field will not be set.")
      private Instant updatedAt;

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

      @Nullable
      @SuppressFBWarnings(justification = "generated code")
      public String getTranslatedScope() {
         return this.translatedScope;
      }

      @SuppressFBWarnings(justification = "generated code")
      public boolean isGranted() {
         return this.granted;
      }

      @Nullable
      @SuppressFBWarnings(justification = "generated code")
      public Instant getUpdatedAt() {
         return this.updatedAt;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      public void setTranslatedScope(@Nullable String translatedScope) {
         this.translatedScope = translatedScope;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setGranted(boolean granted) {
         this.granted = granted;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setUpdatedAt(@Nullable Instant updatedAt) {
         this.updatedAt = updatedAt;
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public boolean equals(Object o) {
         if (o == this) {
            return true;
         } else if (!(o instanceof OAuth2LocalConsentAttributeData.ScopeAttributeData other)) {
            return false;
         } else {
            if (!other.canEqual(this)) {
               return false;
            }

            if (this.granted != other.granted) {
               return false;
            }

            Object this$scope = this.scope;
            Object other$scope = other.scope;
            if (this$scope == null ? other$scope == null : this$scope.equals(other$scope)) {
               Object this$translatedScope = this.translatedScope;
               Object other$translatedScope = other.translatedScope;
               if (this$translatedScope == null ? other$translatedScope == null : this$translatedScope.equals(other$translatedScope)) {
                  Object this$updatedAt = this.updatedAt;
                  Object other$updatedAt = other.updatedAt;
                  return this$updatedAt == null ? other$updatedAt == null : this$updatedAt.equals(other$updatedAt);
               } else {
                  return false;
               }
            } else {
               return false;
            }
         }
      }

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

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2LocalConsentAttributeData.ScopeAttributeData(scope="
            + this.getScope()
            + ", translatedScope="
            + this.getTranslatedScope()
            + ", granted="
            + this.isGranted()
            + ", updatedAt="
            + this.getUpdatedAt()
            + ")";
      }

      @SuppressFBWarnings(justification = "generated code")
      public ScopeAttributeData(String scope, @Nullable String translatedScope, boolean granted, @Nullable Instant updatedAt) {
         this.scope = scope;
         this.translatedScope = translatedScope;
         this.granted = granted;
         this.updatedAt = updatedAt;
      }

      @SuppressFBWarnings(justification = "generated code")
      public ScopeAttributeData() {
      }
   }
}
