package com.airlock.iam.admin.domain.model.token.vasco;

import com.airlock.iam.admin.application.service.token.vasco.VascoOtpAssignParameters;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
import java.util.Objects;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;

public final class VascoOtpAssignment {
   private final String userId;
   private final String assignedBy;
   private final Date assignmentDate;
   private final Optional<String> additionalInfo;
   private final Optional<String> comment;

   public boolean hasAdditionalInfo() {
      return this.additionalInfo.isPresent();
   }

   public boolean hasComment() {
      return this.comment.isPresent();
   }

   private VascoOtpAssignment(String userId, String assignedBy, Date assignmentDate, Optional<String> additionalInfo, Optional<String> comment) {
      this.userId = Objects.requireNonNull(userId);
      this.assignedBy = Objects.requireNonNull(assignedBy);
      this.assignmentDate = assignmentDate;
      this.additionalInfo = this.trimToOptionalEmpty(Objects.requireNonNull(additionalInfo));
      this.comment = this.trimToOptionalEmpty(Objects.requireNonNull(comment));
   }

   public static VascoOtpAssignment fromParameters(VascoOtpAssignParameters params, String assignedBy) {
      return new VascoOtpAssignment(params.getUserId(), assignedBy, new Date(), params.getAdditionalInformation(), params.getComment());
   }

   private Optional<String> trimToOptionalEmpty(Optional<String> optional) {
      return optional.map(StringUtils::trimToNull);
   }

   @SuppressFBWarnings(justification = "generated code")
   public static VascoOtpAssignment.VascoOtpAssignmentBuilder builder() {
      return new VascoOtpAssignment.VascoOtpAssignmentBuilder();
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public Date getAssignmentDate() {
      return this.assignmentDate;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<String> getAdditionalInfo() {
      return this.additionalInfo;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<String> getComment() {
      return this.comment;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "VascoOtpAssignment(userId="
         + this.getUserId()
         + ", assignedBy="
         + this.getAssignedBy()
         + ", assignmentDate="
         + this.getAssignmentDate()
         + ", additionalInfo="
         + this.getAdditionalInfo()
         + ", comment="
         + this.getComment()
         + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class VascoOtpAssignmentBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String userId;
      @SuppressFBWarnings(justification = "generated code")
      private String assignedBy;
      @SuppressFBWarnings(justification = "generated code")
      private Date assignmentDate;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<String> additionalInfo;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<String> comment;

      @SuppressFBWarnings(justification = "generated code")
      VascoOtpAssignmentBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public VascoOtpAssignment.VascoOtpAssignmentBuilder userId(String userId) {
         this.userId = userId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public VascoOtpAssignment.VascoOtpAssignmentBuilder assignedBy(String assignedBy) {
         this.assignedBy = assignedBy;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public VascoOtpAssignment.VascoOtpAssignmentBuilder assignmentDate(Date assignmentDate) {
         this.assignmentDate = assignmentDate;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public VascoOtpAssignment.VascoOtpAssignmentBuilder additionalInfo(Optional<String> additionalInfo) {
         this.additionalInfo = additionalInfo;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public VascoOtpAssignment.VascoOtpAssignmentBuilder comment(Optional<String> comment) {
         this.comment = comment;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public VascoOtpAssignment build() {
         return new VascoOtpAssignment(this.userId, this.assignedBy, this.assignmentDate, this.additionalInfo, this.comment);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "VascoOtpAssignment.VascoOtpAssignmentBuilder(userId="
            + this.userId
            + ", assignedBy="
            + this.assignedBy
            + ", assignmentDate="
            + this.assignmentDate
            + ", additionalInfo="
            + this.additionalInfo
            + ", comment="
            + this.comment
            + ")";
      }
   }
}
