package com.airlock.iam.flow.application.configuration.selection.step;

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.MapificationUtils;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import com.airlock.iam.flow.api.domain.model.selection.Option;
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;

public final class SelectionOptions implements StepResultDataCollection<Option>, Mapifiable {
   private static final String OPTIONS_KEY = "options";
   private final Set<Option> options;

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

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

   public static SelectionOptions demapify(MapifiedValues values) {
      return new SelectionOptions(values.demapifySet("options", OptionMapificationUtil::demapify));
   }

   @SuppressFBWarnings(justification = "generated code")
   public SelectionOptions(Set<Option> options) {
      this.options = options;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof SelectionOptions 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 "SelectionOptions(options=" + this.getOptions() + ")";
   }
}
