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

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NonNull;

public final class Option {
   public static final Option FALLBACK_OPTION = of("#FALLBACK");
   @NonNull
   private final String name;
   private final boolean lastSelected;

   public static Option of(String name) {
      return new Option(name, false);
   }

   public static Option lastSelectedOptionOf(String name) {
      return new Option(name, true);
   }

   @Override
   public String toString() {
      return this.name;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public Option(@NonNull String name, boolean lastSelected) {
      if (name == null) {
         throw new NullPointerException("name is marked non-null but is null");
      }

      this.name = name;
      this.lastSelected = lastSelected;
   }

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

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