package com.airlock.iam.flow.domain.model.selection.step;

import com.airlock.iam.base.api.domain.model.plugin.LogicForConfig;
import com.airlock.iam.flow.api.application.configuration.selection.CommonSelectionOptionConfig;
import com.airlock.iam.flow.api.domain.model.selection.Option;
import com.airlock.iam.flow.api.domain.model.step.FlowCondition;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.inject.Inject;

@LogicForConfig(CommonSelectionOptionConfig.class)
public final class SelectableOption {
   private final Option option;
   private final FlowCondition condition;

   @Inject
   public SelectableOption(Option option, FlowCondition condition) {
      this.option = option;
      this.condition = condition;
   }

   public boolean isSelectable() {
      return this.condition.isFulfilled();
   }

   @SuppressFBWarnings(justification = "generated code")
   public Option getOption() {
      return this.option;
   }

   @SuppressFBWarnings(justification = "generated code")
   public FlowCondition getCondition() {
      return this.condition;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "SelectableOption(option=" + this.getOption() + ", condition=" + this.getCondition() + ")";
   }
}
