package com.airlock.iam.admin.application.service.settings;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import lombok.NonNull;

@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public class AdminappPageSettings {
   @NonNull
   private Map<String, Settings> pages;

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

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Map<String, Settings> getPages() {
      return this.pages;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setPages(@NonNull Map<String, Settings> pages) {
      if (pages == null) {
         throw new NullPointerException("pages is marked non-null but is null");
      }

      this.pages = pages;
   }

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

         Object this$pages = this.pages;
         Object other$pages = other.pages;
         return this$pages == null ? other$pages == null : this$pages.equals(other$pages);
      }
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "AdminappPageSettings(pages=" + this.getPages() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public AdminappPageSettings(@NonNull Map<String, Settings> pages) {
      if (pages == null) {
         throw new NullPointerException("pages is marked non-null but is null");
      }

      this.pages = pages;
   }

   @SuppressFBWarnings(justification = "generated code")
   public AdminappPageSettings() {
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class AdminappPageSettingsBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<String> pages$key;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<Settings> pages$value;

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

      @SuppressFBWarnings(justification = "generated code")
      public AdminappPageSettings.AdminappPageSettingsBuilder page(String pageKey, Settings pageValue) {
         if (this.pages$key == null) {
            this.pages$key = new ArrayList<>();
            this.pages$value = new ArrayList<>();
         }

         this.pages$key.add(pageKey);
         this.pages$value.add(pageValue);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public AdminappPageSettings.AdminappPageSettingsBuilder pages(Map<? extends String, ? extends Settings> pages) {
         if (pages == null) {
            throw new NullPointerException("pages cannot be null");
         }

         if (this.pages$key == null) {
            this.pages$key = new ArrayList<>();
            this.pages$value = new ArrayList<>();
         }

         for (Entry<? extends String, ? extends Settings> $lombokEntry : pages.entrySet()) {
            this.pages$key.add($lombokEntry.getKey());
            this.pages$value.add($lombokEntry.getValue());
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public AdminappPageSettings.AdminappPageSettingsBuilder clearPages() {
         if (this.pages$key != null) {
            this.pages$key.clear();
            this.pages$value.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public AdminappPageSettings build() {
         return new AdminappPageSettings(
            switch (this.pages$key == null ? 0 : this.pages$key.size()) {
               case 0 -> Collections.emptyMap();
               case 1 -> Collections.singletonMap(this.pages$key.get(0), this.pages$value.get(0));
               default -> {
                  Map<String, Settings> pages = new LinkedHashMap<>(
                     this.pages$key.size() < 1073741824 ? 1 + this.pages$key.size() + (this.pages$key.size() - 3) / 3 : Integer.MAX_VALUE
                  );

                  for (int $i = 0; $i < this.pages$key.size(); $i++) {
                     pages.put(this.pages$key.get($i), this.pages$value.get($i));
                  }

                  yield Collections.unmodifiableMap(pages);
               }
            }
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "AdminappPageSettings.AdminappPageSettingsBuilder(pages$key=" + this.pages$key + ", pages$value=" + this.pages$value + ")";
      }
   }
}
