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

import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import com.airlock.iam.common.domain.model.termsofservice.TermsOfServiceTag;
import com.airlock.iam.flow.api.domain.model.step.StepResultData;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public final class TermsOfServiceEntry implements StepResultData {
   private static final String DISCLAIMER_KEY = "disclaimer";
   private static final String TAG_KEY = "tag";
   private final TermsOfServiceTag tag;
   private final String disclaimerText;

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues().put("tag", this.tag.getName()).put("disclaimer", this.disclaimerText).build();
   }

   public static TermsOfServiceEntry demapify(MapifiedValues values) {
      return new TermsOfServiceEntry(new TermsOfServiceTag(values.get("tag")), values.get("disclaimer"));
   }

   @SuppressFBWarnings(justification = "generated code")
   public TermsOfServiceEntry(TermsOfServiceTag tag, String disclaimerText) {
      this.tag = tag;
      this.disclaimerText = disclaimerText;
   }

   @SuppressFBWarnings(justification = "generated code")
   public TermsOfServiceTag getTag() {
      return this.tag;
   }

   @SuppressFBWarnings(justification = "generated code")
   public String getDisclaimerText() {
      return this.disclaimerText;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "TermsOfServiceEntry(tag=" + this.getTag() + ", disclaimerText=" + this.getDisclaimerText() + ")";
   }
}
