package com.airlock.iam.oauth2.domain.service.consent;

import com.airlock.iam.oauth2.api.domain.model.OAuth2Scope;
import com.airlock.iam.oauth2.domain.model.provider.OAuth2ScopeAttribute;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
import java.util.Optional;
import java.util.Set;

public interface OAuth2ConsentService {
   OAuth2ConsentService.PreProcessConsentResult preProcess(List<OAuth2Scope> var1);

   Optional<OAuth2ConsentService.PreProcessConsentResult.ConsentResultError> validate(List<OAuth2ScopeAttribute> var1, Set<String> var2);

   void saveConsentResults(Set<String> var1, Set<String> var2);

   List<OAuth2ScopeAttribute> loadSavedConsents(List<OAuth2Scope> var1);

   boolean isConsentStorageEnabled();

   final class PreProcessConsentResult {
      private final Optional<OAuth2ConsentService.PreProcessConsentResult.ConsentResultError> error;
      private final Optional<List<OAuth2Scope>> grantableScopes;
      private final Optional<Set<OAuth2Scope>> alwaysGrantedScopes;

      public PreProcessConsentResult(OAuth2ConsentService.PreProcessConsentResult.ConsentResultError error) {
         this.error = Optional.of(error);
         this.grantableScopes = Optional.empty();
         this.alwaysGrantedScopes = Optional.empty();
      }

      public PreProcessConsentResult(List<OAuth2Scope> grantableScopes, Set<OAuth2Scope> alwaysGrantedScopes) {
         this.error = Optional.empty();
         this.grantableScopes = Optional.of(grantableScopes);
         this.alwaysGrantedScopes = Optional.of(alwaysGrantedScopes);
      }

      @SuppressFBWarnings(justification = "generated code")
      public Optional<OAuth2ConsentService.PreProcessConsentResult.ConsentResultError> getError() {
         return this.error;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      public Optional<Set<OAuth2Scope>> getAlwaysGrantedScopes() {
         return this.alwaysGrantedScopes;
      }

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

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2ConsentService.PreProcessConsentResult(error="
            + this.getError()
            + ", grantableScopes="
            + this.getGrantableScopes()
            + ", alwaysGrantedScopes="
            + this.getAlwaysGrantedScopes()
            + ")";
      }

      @SuppressFBWarnings(justification = "generated code")
      private PreProcessConsentResult(
         Optional<OAuth2ConsentService.PreProcessConsentResult.ConsentResultError> error,
         Optional<List<OAuth2Scope>> grantableScopes,
         Optional<Set<OAuth2Scope>> alwaysGrantedScopes
      ) {
         this.error = error;
         this.grantableScopes = grantableScopes;
         this.alwaysGrantedScopes = alwaysGrantedScopes;
      }

      public enum ConsentResultError {
         EMTPY_SCOPE_NOT_ALLOWED,
         INVALID_SCOPE;
      }
   }
}
