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

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.flowcontrol.InteractiveGotoTarget;
import com.airlock.iam.flow.api.domain.model.step.StepResultDataCollection;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
import java.util.List;
import lombok.NonNull;

public final class InteractiveGotoTargetCollection implements StepResultDataCollection<InteractiveGotoTarget>, Mapifiable {
   private static final String TARGETS = "targets";
   @NonNull
   private final List<InteractiveGotoTarget> gotoTargets;

   @Override
   public Collection<InteractiveGotoTarget> getElements() {
      return this.gotoTargets;
   }

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

   public static InteractiveGotoTargetCollection demapify(MapifiedValues values) {
      return new InteractiveGotoTargetCollection(values.demapifyList("targets", InteractiveGotoTargetMapificationUtil::demapify));
   }

   @SuppressFBWarnings(justification = "generated code")
   public InteractiveGotoTargetCollection(@NonNull List<InteractiveGotoTarget> gotoTargets) {
      if (gotoTargets == null) {
         throw new NullPointerException("gotoTargets is marked non-null but is null");
      }

      this.gotoTargets = gotoTargets;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public List<InteractiveGotoTarget> getGotoTargets() {
      return this.gotoTargets;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "InteractiveGotoTargetCollection(gotoTargets=" + this.getGotoTargets() + ")";
   }
}
