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

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.session.SingleFlowScopedFlowAttribute;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public final class CaptchaFlowAttribute implements SingleFlowScopedFlowAttribute<CaptchaFlowAttribute> {
   private final CaptchaFlowState state;

   public static CaptchaFlowAttribute captchaStateAttribute(CaptchaFlowState state) {
      return new CaptchaFlowAttribute(state);
   }

   public CaptchaFlowAttribute mergeWith(CaptchaFlowAttribute newState) {
      return newState;
   }

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues().put("state", MapificationUtils.mapifyEnum(this.state)).build();
   }

   public static CaptchaFlowAttribute demapify(MapifiedValues values) {
      return new CaptchaFlowAttribute(MapificationUtils.demapifyEnum(values.getValues("state")));
   }

   @SuppressFBWarnings(justification = "generated code")
   public CaptchaFlowState getState() {
      return this.state;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "CaptchaFlowAttribute(state=" + this.getState() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   private CaptchaFlowAttribute(CaptchaFlowState state) {
      this.state = state;
   }
}
