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

import com.airlock.iam.base.api.domain.model.mapification.Mapifiable;
import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NonNull;

public final class OAuth2RemoteConsentAttribute implements Mapifiable {
   private static final String REDIRECT_URL_KEY = "redirectUrl";
   private static final String TOKEN_KEY = "token";
   @NonNull
   private final String redirectUrl;
   @NonNull
   private final String token;

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues().put("redirectUrl", this.redirectUrl).put("token", this.token).build();
   }

   public static OAuth2RemoteConsentAttribute demapify(MapifiedValues values) {
      return new OAuth2RemoteConsentAttribute(values.get("redirectUrl"), values.get("token"));
   }

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2RemoteConsentAttribute(@NonNull String redirectUrl, @NonNull String token) {
      if (redirectUrl == null) {
         throw new NullPointerException("redirectUrl is marked non-null but is null");
      }

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

      this.redirectUrl = redirectUrl;
      this.token = token;
   }

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

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

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "OAuth2RemoteConsentAttribute(redirectUrl=" + this.getRedirectUrl() + ", token=" + this.getToken() + ")";
   }
}
