package com.airlock.iam.authentication.domain.model.migration;

import com.airlock.iam.base.api.domain.model.mapification.Mapifiable;
import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import com.airlock.iam.flow.api.domain.model.step.StepResultDataCollection;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
import java.util.Set;
import lombok.NonNull;

public final class MigrationSelectionOptions implements StepResultDataCollection<String>, Mapifiable {
   private static final String OPTIONS_KEY = "opts";
   @NonNull
   private final Set<String> options;

   @Override
   public Collection<String> getElements() {
      return this.options;
   }

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues().putIfNotEmpty("opts", this.options).build();
   }

   public static MigrationSelectionOptions demapify(MapifiedValues values) {
      return new MigrationSelectionOptions(Set.copyOf(values.getList("opts")));
   }

   @SuppressFBWarnings(justification = "generated code")
   public MigrationSelectionOptions(@NonNull Set<String> options) {
      if (options == null) {
         throw new NullPointerException("options is marked non-null but is null");
      }

      this.options = options;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Set<String> getOptions() {
      return this.options;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "MigrationSelectionOptions(options=" + this.getOptions() + ")";
   }
}
