package com.airlock.iam.oauth2.domain.model.provider;

import com.airlock.iam.oauth2.domain.model.consent.OAuth2ConsentStatus;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
import java.util.Optional;
import lombok.NonNull;

public final class OAuth2ScopeAttribute {
   @NonNull
   private final String scope;
   @NonNull
   private final Optional<String> translatedScope;
   @NonNull
   private final OAuth2ConsentStatus consentStatus;
   @NonNull
   private final Optional<Instant> updatedAt;

   public static OAuth2ScopeAttribute oAuth2ScopeAttribute(String scope) {
      return new OAuth2ScopeAttribute(scope, Optional.empty(), OAuth2ConsentStatus.UNDECIDED, Optional.empty());
   }

   public static OAuth2ScopeAttribute oAuth2ScopeAttribute(String scope, String translatedScope) {
      return new OAuth2ScopeAttribute(scope, Optional.of(translatedScope), OAuth2ConsentStatus.UNDECIDED, Optional.empty());
   }

   public static OAuth2ScopeAttribute oAuth2ScopeAttribute(String scope, OAuth2ConsentStatus status, Instant updatedAt) {
      return new OAuth2ScopeAttribute(scope, Optional.empty(), status, Optional.of(updatedAt));
   }

   public static OAuth2ScopeAttribute oAuth2ScopeAttribute(String scope, String translatedScope, OAuth2ConsentStatus status, Instant updatedAt) {
      return new OAuth2ScopeAttribute(scope, Optional.of(translatedScope), status, Optional.of(updatedAt));
   }

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

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<String> getTranslatedScope() {
      return this.translatedScope;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public OAuth2ConsentStatus getConsentStatus() {
      return this.consentStatus;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Optional<Instant> getUpdatedAt() {
      return this.updatedAt;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof OAuth2ScopeAttribute other)) {
         return false;
      } else {
         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$consentStatus = this.consentStatus;
               Object other$consentStatus = other.consentStatus;
               if (this$consentStatus == null ? other$consentStatus == null : this$consentStatus.equals(other$consentStatus)) {
                  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;
            }
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      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 $consentStatus = this.consentStatus;
      result = result * 59 + ($consentStatus == null ? 43 : $consentStatus.hashCode());
      Object $updatedAt = this.updatedAt;
      return result * 59 + ($updatedAt == null ? 43 : $updatedAt.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2ScopeAttribute(
      @NonNull String scope, @NonNull Optional<String> translatedScope, @NonNull OAuth2ConsentStatus consentStatus, @NonNull Optional<Instant> updatedAt
   ) {
      if (scope == null) {
         throw new NullPointerException("scope is marked non-null but is null");
      }

      if (translatedScope == null) {
         throw new NullPointerException("translatedScope is marked non-null but is null");
      }

      if (consentStatus == null) {
         throw new NullPointerException("consentStatus is marked non-null but is null");
      }

      if (updatedAt == null) {
         throw new NullPointerException("updatedAt is marked non-null but is null");
      }

      this.scope = scope;
      this.translatedScope = translatedScope;
      this.consentStatus = consentStatus;
      this.updatedAt = updatedAt;
   }
}
