package com.airlock.iam.admin.domain.model.user;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public final class CsvUsersExportSettings {
   private final boolean fullExport;
   private final List<String> contextKeys;
   private final Charset charset;
   private final String separationCharacter;

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

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

   @SuppressFBWarnings(justification = "generated code")
   public List<String> contextKeys() {
      return this.contextKeys;
   }

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

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

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

         Object this$contextKeys = this.contextKeys;
         Object other$contextKeys = other.contextKeys;
         if (this$contextKeys == null ? other$contextKeys == null : this$contextKeys.equals(other$contextKeys)) {
            Object this$charset = this.charset;
            Object other$charset = other.charset;
            if (this$charset == null ? other$charset == null : this$charset.equals(other$charset)) {
               Object this$separationCharacter = this.separationCharacter;
               Object other$separationCharacter = other.separationCharacter;
               return this$separationCharacter == null ? other$separationCharacter == null : this$separationCharacter.equals(other$separationCharacter);
            } else {
               return false;
            }
         } else {
            return false;
         }
      }
   }

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "CsvUsersExportSettings(fullExport="
         + this.fullExport()
         + ", contextKeys="
         + this.contextKeys()
         + ", charset="
         + this.charset()
         + ", separationCharacter="
         + this.separationCharacter()
         + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   private CsvUsersExportSettings(boolean fullExport, List<String> contextKeys, Charset charset, String separationCharacter) {
      this.fullExport = fullExport;
      this.contextKeys = contextKeys;
      this.charset = charset;
      this.separationCharacter = separationCharacter;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class CsvUsersExportSettingsBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private boolean fullExport;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<String> contextKeys;
      @SuppressFBWarnings(justification = "generated code")
      private Charset charset;
      @SuppressFBWarnings(justification = "generated code")
      private String separationCharacter;

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

      @SuppressFBWarnings(justification = "generated code")
      public CsvUsersExportSettings.CsvUsersExportSettingsBuilder fullExport(boolean fullExport) {
         this.fullExport = fullExport;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CsvUsersExportSettings.CsvUsersExportSettingsBuilder contextKey(String contextKey) {
         if (this.contextKeys == null) {
            this.contextKeys = new ArrayList<>();
         }

         this.contextKeys.add(contextKey);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CsvUsersExportSettings.CsvUsersExportSettingsBuilder contextKeys(Collection<? extends String> contextKeys) {
         if (contextKeys == null) {
            throw new NullPointerException("contextKeys cannot be null");
         }

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

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

      @SuppressFBWarnings(justification = "generated code")
      public CsvUsersExportSettings.CsvUsersExportSettingsBuilder clearContextKeys() {
         if (this.contextKeys != null) {
            this.contextKeys.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CsvUsersExportSettings.CsvUsersExportSettingsBuilder charset(Charset charset) {
         this.charset = charset;
         return this;
      }

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

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "CsvUsersExportSettings.CsvUsersExportSettingsBuilder(fullExport="
            + this.fullExport
            + ", contextKeys="
            + this.contextKeys
            + ", charset="
            + this.charset
            + ", separationCharacter="
            + this.separationCharacter
            + ")";
      }
   }
}
