package com.airlock.iam.admin.infrastructure.transfer.request;

import com.fasterxml.jackson.annotation.JsonTypeName;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;

@JsonTypeName("maintenance-message")
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public class MaintenanceMessageRequest {
   public static final String MAINTENANCE_MESSAGE_TYPE = "maintenance-message";
   @Schema(description = "The location (optional, depending on configuration).", nullable = true, type = "string")
   private String location;
   @NotNull
   @Schema(description = "Whether the message is active or not.")
   private Boolean active;
   @NotNull
   @Schema(description = "Whether the system is available when this message is displayed or not.")
   private Boolean systemAvailable;
   @NotNull
   @Schema(description = "The validity start date of this message.")
   private Date validFrom;
   @NotNull
   @Schema(description = "The validity end date of this message.")
   private Date validTo;
   @Schema(
      description = "The translations of this message. This represents a mapping from the ISO-639-1 (2 character) language code to the message (as HTML) in that language."
   )
   private Map<String, String> translations;

   public MaintenanceMessageRequest() {
      this.translations = new HashMap<>();
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public Boolean getActive() {
      return this.active;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Boolean getSystemAvailable() {
      return this.systemAvailable;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Date getValidFrom() {
      return this.validFrom;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Date getValidTo() {
      return this.validTo;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Map<String, String> getTranslations() {
      return this.translations;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setLocation(String location) {
      this.location = location;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setActive(Boolean active) {
      this.active = active;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setSystemAvailable(Boolean systemAvailable) {
      this.systemAvailable = systemAvailable;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setValidFrom(Date validFrom) {
      this.validFrom = validFrom;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setValidTo(Date validTo) {
      this.validTo = validTo;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setTranslations(Map<String, String> translations) {
      this.translations = translations;
   }

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

         Object this$active = this.active;
         Object other$active = other.active;
         if (this$active == null ? other$active == null : this$active.equals(other$active)) {
            Object this$systemAvailable = this.systemAvailable;
            Object other$systemAvailable = other.systemAvailable;
            if (this$systemAvailable == null ? other$systemAvailable == null : this$systemAvailable.equals(other$systemAvailable)) {
               Object this$location = this.location;
               Object other$location = other.location;
               if (this$location == null ? other$location == null : this$location.equals(other$location)) {
                  Object this$validFrom = this.validFrom;
                  Object other$validFrom = other.validFrom;
                  if (this$validFrom == null ? other$validFrom == null : this$validFrom.equals(other$validFrom)) {
                     Object this$validTo = this.validTo;
                     Object other$validTo = other.validTo;
                     if (this$validTo == null ? other$validTo == null : this$validTo.equals(other$validTo)) {
                        Object this$translations = this.translations;
                        Object other$translations = other.translations;
                        return this$translations == null ? other$translations == null : this$translations.equals(other$translations);
                     } 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 MaintenanceMessageRequest;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "MaintenanceMessageRequest(location="
         + this.getLocation()
         + ", active="
         + this.getActive()
         + ", systemAvailable="
         + this.getSystemAvailable()
         + ", validFrom="
         + this.getValidFrom()
         + ", validTo="
         + this.getValidTo()
         + ", translations="
         + this.getTranslations()
         + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public MaintenanceMessageRequest(String location, Boolean active, Boolean systemAvailable, Date validFrom, Date validTo, Map<String, String> translations) {
      this.location = location;
      this.active = active;
      this.systemAvailable = systemAvailable;
      this.validFrom = validFrom;
      this.validTo = validTo;
      this.translations = translations;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class MaintenanceMessageRequestBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String location;
      @SuppressFBWarnings(justification = "generated code")
      private Boolean active;
      @SuppressFBWarnings(justification = "generated code")
      private Boolean systemAvailable;
      @SuppressFBWarnings(justification = "generated code")
      private Date validFrom;
      @SuppressFBWarnings(justification = "generated code")
      private Date validTo;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<String> translations$key;
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<String> translations$value;

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

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

      @SuppressFBWarnings(justification = "generated code")
      public MaintenanceMessageRequest.MaintenanceMessageRequestBuilder active(Boolean active) {
         this.active = active;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MaintenanceMessageRequest.MaintenanceMessageRequestBuilder systemAvailable(Boolean systemAvailable) {
         this.systemAvailable = systemAvailable;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MaintenanceMessageRequest.MaintenanceMessageRequestBuilder validFrom(Date validFrom) {
         this.validFrom = validFrom;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MaintenanceMessageRequest.MaintenanceMessageRequestBuilder validTo(Date validTo) {
         this.validTo = validTo;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MaintenanceMessageRequest.MaintenanceMessageRequestBuilder translation(String translationKey, String translationValue) {
         if (this.translations$key == null) {
            this.translations$key = new ArrayList<>();
            this.translations$value = new ArrayList<>();
         }

         this.translations$key.add(translationKey);
         this.translations$value.add(translationValue);
         return this;
      }

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

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

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

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MaintenanceMessageRequest.MaintenanceMessageRequestBuilder clearTranslations() {
         if (this.translations$key != null) {
            this.translations$key.clear();
            this.translations$value.clear();
         }

         return this;
      }

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "MaintenanceMessageRequest.MaintenanceMessageRequestBuilder(location="
            + this.location
            + ", active="
            + this.active
            + ", systemAvailable="
            + this.systemAvailable
            + ", validFrom="
            + this.validFrom
            + ", validTo="
            + this.validTo
            + ", translations$key="
            + this.translations$key
            + ", translations$value="
            + this.translations$value
            + ")";
      }
   }
}
