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

import com.airlock.iam.base.api.domain.model.Entity;
import com.airlock.iam.base.api.domain.model.user.UserId;
import com.airlock.iam.oauth2.api.domain.model.AuthorizationServerId;
import com.airlock.iam.oauth2.api.domain.model.OAuth2ClientId;
import com.airlock.iam.oauth2.api.domain.model.OAuth2Scope;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
import lombok.NonNull;

public class OAuth2Consent implements Entity<OAuth2Consent> {
   @NonNull
   private final OAuth2ConsentId id;
   @NonNull
   private final OAuth2ClientId clientId;
   @NonNull
   private final AuthorizationServerId authorizationServerId;
   @NonNull
   private final UserId userId;
   @NonNull
   private final OAuth2Scope scope;
   @NonNull
   private OAuth2ConsentStatus status;
   @NonNull
   private Instant updatedAt;

   @SuppressFBWarnings(justification = "generated code")
   public static OAuth2Consent.OAuth2ConsentBuilder builder() {
      return new OAuth2Consent.OAuth2ConsentBuilder();
   }

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2Consent(
      @NonNull OAuth2ConsentId id,
      @NonNull OAuth2ClientId clientId,
      @NonNull AuthorizationServerId authorizationServerId,
      @NonNull UserId userId,
      @NonNull OAuth2Scope scope,
      @NonNull OAuth2ConsentStatus status,
      @NonNull Instant updatedAt
   ) {
      if (id == null) {
         throw new NullPointerException("id is marked non-null but is null");
      }

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

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

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

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

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

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

      this.id = id;
      this.clientId = clientId;
      this.authorizationServerId = authorizationServerId;
      this.userId = userId;
      this.scope = scope;
      this.status = status;
      this.updatedAt = updatedAt;
   }

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

         Object this$id = this.id;
         Object other$id = other.id;
         if (this$id == null ? other$id == null : this$id.equals(other$id)) {
            Object this$clientId = this.clientId;
            Object other$clientId = other.clientId;
            if (this$clientId == null ? other$clientId == null : this$clientId.equals(other$clientId)) {
               Object this$authorizationServerId = this.authorizationServerId;
               Object other$authorizationServerId = other.authorizationServerId;
               if (this$authorizationServerId == null ? other$authorizationServerId == null : this$authorizationServerId.equals(other$authorizationServerId)) {
                  Object this$userId = this.userId;
                  Object other$userId = other.userId;
                  if (this$userId == null ? other$userId == null : this$userId.equals(other$userId)) {
                     Object this$scope = this.scope;
                     Object other$scope = other.scope;
                     if (this$scope == null ? other$scope == null : this$scope.equals(other$scope)) {
                        Object this$status = this.status;
                        Object other$status = other.status;
                        if (this$status == null ? other$status == null : this$status.equals(other$status)) {
                           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;
                  }
               } else {
                  return false;
               }
            } else {
               return false;
            }
         } else {
            return false;
         }
      }
   }

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      Object $id = this.id;
      result = result * 59 + ($id == null ? 43 : $id.hashCode());
      Object $clientId = this.clientId;
      result = result * 59 + ($clientId == null ? 43 : $clientId.hashCode());
      Object $authorizationServerId = this.authorizationServerId;
      result = result * 59 + ($authorizationServerId == null ? 43 : $authorizationServerId.hashCode());
      Object $userId = this.userId;
      result = result * 59 + ($userId == null ? 43 : $userId.hashCode());
      Object $scope = this.scope;
      result = result * 59 + ($scope == null ? 43 : $scope.hashCode());
      Object $status = this.status;
      result = result * 59 + ($status == null ? 43 : $status.hashCode());
      Object $updatedAt = this.updatedAt;
      return result * 59 + ($updatedAt == null ? 43 : $updatedAt.hashCode());
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public OAuth2ConsentId getId() {
      return this.id;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public OAuth2ClientId getClientId() {
      return this.clientId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public AuthorizationServerId getAuthorizationServerId() {
      return this.authorizationServerId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public UserId getUserId() {
      return this.userId;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public void setStatus(@NonNull OAuth2ConsentStatus status) {
      if (status == null) {
         throw new NullPointerException("status is marked non-null but is null");
      }

      this.status = status;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public void setUpdatedAt(@NonNull Instant updatedAt) {
      if (updatedAt == null) {
         throw new NullPointerException("updatedAt is marked non-null but is null");
      }

      this.updatedAt = updatedAt;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2ConsentBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private OAuth2ConsentId id;
      @SuppressFBWarnings(justification = "generated code")
      private OAuth2ClientId clientId;
      @SuppressFBWarnings(justification = "generated code")
      private AuthorizationServerId authorizationServerId;
      @SuppressFBWarnings(justification = "generated code")
      private UserId userId;
      @SuppressFBWarnings(justification = "generated code")
      private OAuth2Scope scope;
      @SuppressFBWarnings(justification = "generated code")
      private OAuth2ConsentStatus status;
      @SuppressFBWarnings(justification = "generated code")
      private Instant updatedAt;

      @SuppressFBWarnings(justification = "generated code")
      OAuth2ConsentBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2Consent.OAuth2ConsentBuilder id(@NonNull OAuth2ConsentId id) {
         if (id == null) {
            throw new NullPointerException("id is marked non-null but is null");
         }

         this.id = id;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2Consent.OAuth2ConsentBuilder clientId(@NonNull OAuth2ClientId clientId) {
         if (clientId == null) {
            throw new NullPointerException("clientId is marked non-null but is null");
         }

         this.clientId = clientId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2Consent.OAuth2ConsentBuilder authorizationServerId(@NonNull AuthorizationServerId authorizationServerId) {
         if (authorizationServerId == null) {
            throw new NullPointerException("authorizationServerId is marked non-null but is null");
         }

         this.authorizationServerId = authorizationServerId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2Consent.OAuth2ConsentBuilder userId(@NonNull UserId userId) {
         if (userId == null) {
            throw new NullPointerException("userId is marked non-null but is null");
         }

         this.userId = userId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2Consent.OAuth2ConsentBuilder scope(@NonNull OAuth2Scope scope) {
         if (scope == null) {
            throw new NullPointerException("scope is marked non-null but is null");
         }

         this.scope = scope;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2Consent.OAuth2ConsentBuilder status(@NonNull OAuth2ConsentStatus status) {
         if (status == null) {
            throw new NullPointerException("status is marked non-null but is null");
         }

         this.status = status;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2Consent.OAuth2ConsentBuilder updatedAt(@NonNull Instant updatedAt) {
         if (updatedAt == null) {
            throw new NullPointerException("updatedAt is marked non-null but is null");
         }

         this.updatedAt = updatedAt;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2Consent build() {
         return new OAuth2Consent(this.id, this.clientId, this.authorizationServerId, this.userId, this.scope, this.status, this.updatedAt);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2Consent.OAuth2ConsentBuilder(id="
            + this.id
            + ", clientId="
            + this.clientId
            + ", authorizationServerId="
            + this.authorizationServerId
            + ", userId="
            + this.userId
            + ", scope="
            + this.scope
            + ", status="
            + this.status
            + ", updatedAt="
            + this.updatedAt
            + ")";
      }
   }
}
