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

import com.airlock.iam.oauth2.domain.model.State;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.annotation.Nullable;
import java.util.Optional;

public final class OAuth2AuthorizationSuccessResponse {
   private final Optional<State> state;
   private final Optional<OAuth2AuthorizationSuccessResponse.OAuth2AuthorizationCode> code;

   public OAuth2AuthorizationSuccessResponse(@Nullable State state, @Nullable OAuth2AuthorizationSuccessResponse.OAuth2AuthorizationCode code) {
      this.state = Optional.ofNullable(state);
      this.code = Optional.ofNullable(code);
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<State> getState() {
      return this.state;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<OAuth2AuthorizationSuccessResponse.OAuth2AuthorizationCode> getCode() {
      return this.code;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "OAuth2AuthorizationSuccessResponse(state=" + this.getState() + ", code=" + this.getCode() + ")";
   }

   public static final class OAuth2AuthorizationCode {
      private final String value;

      public static OAuth2AuthorizationSuccessResponse.OAuth2AuthorizationCode oAuth2AuthorizationCode(String code) {
         return new OAuth2AuthorizationSuccessResponse.OAuth2AuthorizationCode(code);
      }

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2AuthorizationSuccessResponse.OAuth2AuthorizationCode(value=" + this.value() + ")";
      }

      @SuppressFBWarnings(justification = "generated code")
      private OAuth2AuthorizationCode(String value) {
         this.value = value;
      }
   }
}
