package com.airlock.iam.authentication.domain.model.secretquestions;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import lombok.NonNull;

public final class SecretQuestionsProvision {
   @NonNull
   @SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
   private final List<SecretQuestionProvision> provisionedQuestions;

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

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public List<SecretQuestionProvision> getProvisionedQuestions() {
      return this.provisionedQuestions;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "SecretQuestionsProvision(provisionedQuestions=" + this.getProvisionedQuestions() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public SecretQuestionsProvision(@NonNull List<SecretQuestionProvision> provisionedQuestions) {
      if (provisionedQuestions == null) {
         throw new NullPointerException("provisionedQuestions is marked non-null but is null");
      }

      this.provisionedQuestions = provisionedQuestions;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class SecretQuestionsProvisionBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<SecretQuestionProvision> provisionedQuestions;

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

      @SuppressFBWarnings(justification = "generated code")
      public SecretQuestionsProvision.SecretQuestionsProvisionBuilder provisionedQuestion(SecretQuestionProvision provisionedQuestion) {
         if (this.provisionedQuestions == null) {
            this.provisionedQuestions = new ArrayList<>();
         }

         this.provisionedQuestions.add(provisionedQuestion);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SecretQuestionsProvision.SecretQuestionsProvisionBuilder provisionedQuestions(Collection<? extends SecretQuestionProvision> provisionedQuestions) {
         if (provisionedQuestions == null) {
            throw new NullPointerException("provisionedQuestions cannot be null");
         }

         if (this.provisionedQuestions == null) {
            this.provisionedQuestions = new ArrayList<>();
         }

         this.provisionedQuestions.addAll(provisionedQuestions);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SecretQuestionsProvision.SecretQuestionsProvisionBuilder clearProvisionedQuestions() {
         if (this.provisionedQuestions != null) {
            this.provisionedQuestions.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SecretQuestionsProvision build() {
         return new SecretQuestionsProvision(switch (this.provisionedQuestions == null ? 0 : this.provisionedQuestions.size()) {
            case 0 -> Collections.emptyList();
            case 1 -> Collections.singletonList(this.provisionedQuestions.get(0));
            default -> Collections.unmodifiableList(new ArrayList<>(this.provisionedQuestions));
         });
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "SecretQuestionsProvision.SecretQuestionsProvisionBuilder(provisionedQuestions=" + this.provisionedQuestions + ")";
      }
   }
}
