package com.airlock.iam.admin.domain.model.token.generic;

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

public final class GenericTokenUi {
   private final List<GenericTokenUiElement> uiElements;
   private final boolean showAddButton;
   private final boolean showSaveButton;
   private final boolean showDeleteButton;
   private final boolean showEnableButton;
   private final boolean showDisableButton;
   private final boolean showActivationOrder;
   private final boolean showOrderActivationButton;
   private final boolean showCancelActivationButton;
   private final String enabledProperty;
   private final int maxTokenCount;

   public Optional<String> getEnabledProperty() {
      return Optional.ofNullable(this.enabledProperty);
   }

   @SuppressFBWarnings(justification = "generated code")
   GenericTokenUi(
      List<GenericTokenUiElement> uiElements,
      boolean showAddButton,
      boolean showSaveButton,
      boolean showDeleteButton,
      boolean showEnableButton,
      boolean showDisableButton,
      boolean showActivationOrder,
      boolean showOrderActivationButton,
      boolean showCancelActivationButton,
      String enabledProperty,
      int maxTokenCount
   ) {
      this.uiElements = uiElements;
      this.showAddButton = showAddButton;
      this.showSaveButton = showSaveButton;
      this.showDeleteButton = showDeleteButton;
      this.showEnableButton = showEnableButton;
      this.showDisableButton = showDisableButton;
      this.showActivationOrder = showActivationOrder;
      this.showOrderActivationButton = showOrderActivationButton;
      this.showCancelActivationButton = showCancelActivationButton;
      this.enabledProperty = enabledProperty;
      this.maxTokenCount = maxTokenCount;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public GenericTokenUi.GenericTokenUiBuilder toBuilder() {
      GenericTokenUi.GenericTokenUiBuilder builder = new GenericTokenUi.GenericTokenUiBuilder()
         .showAddButton(this.showAddButton)
         .showSaveButton(this.showSaveButton)
         .showDeleteButton(this.showDeleteButton)
         .showEnableButton(this.showEnableButton)
         .showDisableButton(this.showDisableButton)
         .showActivationOrder(this.showActivationOrder)
         .showOrderActivationButton(this.showOrderActivationButton)
         .showCancelActivationButton(this.showCancelActivationButton)
         .enabledProperty(this.enabledProperty)
         .maxTokenCount(this.maxTokenCount);
      if (this.uiElements != null) {
         builder.uiElements(this.uiElements);
      }

      return builder;
   }

   @SuppressFBWarnings(justification = "generated code")
   public List<GenericTokenUiElement> getUiElements() {
      return this.uiElements;
   }

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

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

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

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

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

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

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

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

   @SuppressFBWarnings(justification = "generated code")
   public int getMaxTokenCount() {
      return this.maxTokenCount;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof GenericTokenUi other)) {
         return false;
      } else if (this.showAddButton != other.showAddButton) {
         return false;
      } else if (this.showSaveButton != other.showSaveButton) {
         return false;
      } else if (this.showDeleteButton != other.showDeleteButton) {
         return false;
      } else if (this.showEnableButton != other.showEnableButton) {
         return false;
      } else if (this.showDisableButton != other.showDisableButton) {
         return false;
      } else if (this.showActivationOrder != other.showActivationOrder) {
         return false;
      } else if (this.showOrderActivationButton != other.showOrderActivationButton) {
         return false;
      } else if (this.showCancelActivationButton != other.showCancelActivationButton) {
         return false;
      } else if (this.maxTokenCount != other.maxTokenCount) {
         return false;
      } else {
         Object this$uiElements = this.uiElements;
         Object other$uiElements = other.uiElements;
         if (this$uiElements == null ? other$uiElements == null : this$uiElements.equals(other$uiElements)) {
            Object this$enabledProperty = this.enabledProperty;
            Object other$enabledProperty = other.enabledProperty;
            return this$enabledProperty == null ? other$enabledProperty == null : this$enabledProperty.equals(other$enabledProperty);
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      result = result * 59 + (this.showAddButton ? 79 : 97);
      result = result * 59 + (this.showSaveButton ? 79 : 97);
      result = result * 59 + (this.showDeleteButton ? 79 : 97);
      result = result * 59 + (this.showEnableButton ? 79 : 97);
      result = result * 59 + (this.showDisableButton ? 79 : 97);
      result = result * 59 + (this.showActivationOrder ? 79 : 97);
      result = result * 59 + (this.showOrderActivationButton ? 79 : 97);
      result = result * 59 + (this.showCancelActivationButton ? 79 : 97);
      result = result * 59 + this.maxTokenCount;
      Object $uiElements = this.uiElements;
      result = result * 59 + ($uiElements == null ? 43 : $uiElements.hashCode());
      Object $enabledProperty = this.enabledProperty;
      return result * 59 + ($enabledProperty == null ? 43 : $enabledProperty.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "GenericTokenUi(uiElements="
         + this.getUiElements()
         + ", showAddButton="
         + this.isShowAddButton()
         + ", showSaveButton="
         + this.isShowSaveButton()
         + ", showDeleteButton="
         + this.isShowDeleteButton()
         + ", showEnableButton="
         + this.isShowEnableButton()
         + ", showDisableButton="
         + this.isShowDisableButton()
         + ", showActivationOrder="
         + this.isShowActivationOrder()
         + ", showOrderActivationButton="
         + this.isShowOrderActivationButton()
         + ", showCancelActivationButton="
         + this.isShowCancelActivationButton()
         + ", enabledProperty="
         + this.getEnabledProperty()
         + ", maxTokenCount="
         + this.getMaxTokenCount()
         + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class GenericTokenUiBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<GenericTokenUiElement> uiElements;
      @SuppressFBWarnings(justification = "generated code")
      private boolean showAddButton;
      @SuppressFBWarnings(justification = "generated code")
      private boolean showSaveButton;
      @SuppressFBWarnings(justification = "generated code")
      private boolean showDeleteButton;
      @SuppressFBWarnings(justification = "generated code")
      private boolean showEnableButton;
      @SuppressFBWarnings(justification = "generated code")
      private boolean showDisableButton;
      @SuppressFBWarnings(justification = "generated code")
      private boolean showActivationOrder;
      @SuppressFBWarnings(justification = "generated code")
      private boolean showOrderActivationButton;
      @SuppressFBWarnings(justification = "generated code")
      private boolean showCancelActivationButton;
      @SuppressFBWarnings(justification = "generated code")
      private String enabledProperty;
      @SuppressFBWarnings(justification = "generated code")
      private int maxTokenCount;

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

      @SuppressFBWarnings(justification = "generated code")
      public GenericTokenUi.GenericTokenUiBuilder uiElement(GenericTokenUiElement uiElement) {
         if (this.uiElements == null) {
            this.uiElements = new ArrayList<>();
         }

         this.uiElements.add(uiElement);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public GenericTokenUi.GenericTokenUiBuilder uiElements(Collection<? extends GenericTokenUiElement> uiElements) {
         if (uiElements == null) {
            throw new NullPointerException("uiElements cannot be null");
         }

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

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

      @SuppressFBWarnings(justification = "generated code")
      public GenericTokenUi.GenericTokenUiBuilder clearUiElements() {
         if (this.uiElements != null) {
            this.uiElements.clear();
         }

         return this;
      }

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

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

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

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

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

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      public GenericTokenUi.GenericTokenUiBuilder maxTokenCount(int maxTokenCount) {
         this.maxTokenCount = maxTokenCount;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public GenericTokenUi build() {
         return new GenericTokenUi(
            switch (this.uiElements == null ? 0 : this.uiElements.size()) {
               case 0 -> Collections.emptyList();
               case 1 -> Collections.singletonList(this.uiElements.get(0));
               default -> Collections.unmodifiableList(new ArrayList<>(this.uiElements));
            },
            this.showAddButton,
            this.showSaveButton,
            this.showDeleteButton,
            this.showEnableButton,
            this.showDisableButton,
            this.showActivationOrder,
            this.showOrderActivationButton,
            this.showCancelActivationButton,
            this.enabledProperty,
            this.maxTokenCount
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "GenericTokenUi.GenericTokenUiBuilder(uiElements="
            + this.uiElements
            + ", showAddButton="
            + this.showAddButton
            + ", showSaveButton="
            + this.showSaveButton
            + ", showDeleteButton="
            + this.showDeleteButton
            + ", showEnableButton="
            + this.showEnableButton
            + ", showDisableButton="
            + this.showDisableButton
            + ", showActivationOrder="
            + this.showActivationOrder
            + ", showOrderActivationButton="
            + this.showOrderActivationButton
            + ", showCancelActivationButton="
            + this.showCancelActivationButton
            + ", enabledProperty="
            + this.enabledProperty
            + ", maxTokenCount="
            + this.maxTokenCount
            + ")";
      }
   }
}
