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

import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.flow.api.domain.model.step.InternalStepResultData;
import com.airlock.iam.flow.api.domain.model.step.StepId;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.HashMap;
import java.util.Map;
import lombok.NonNull;

public final class GotoTargetData implements InternalStepResultData {
   private static final String TARGET_STEP_ID_KEY = "targetStepId";
   @NonNull
   private final StepId targetStepId;

   @Override
   public MapifiedValues mapify() {
      Map<String, Object> values = new HashMap<>();
      values.put("targetStepId", this.targetStepId.stepId());
      return new MapifiedValues(values);
   }

   public static GotoTargetData demapify(MapifiedValues values) {
      return new GotoTargetData(new StepId(values.get("targetStepId")));
   }

   @SuppressFBWarnings(justification = "generated code")
   public GotoTargetData(@NonNull StepId targetStepId) {
      if (targetStepId == null) {
         throw new NullPointerException("targetStepId is marked non-null but is null");
      }

      this.targetStepId = targetStepId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public StepId getTargetStepId() {
      return this.targetStepId;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "GotoTargetData(targetStepId=" + this.getTargetStepId() + ")";
   }
}
