package com.airlock.iam.admin.infrastructure.transfer.response.user;

import com.fasterxml.jackson.annotation.JsonTypeName;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.extensions.Extension;
import io.swagger.v3.oas.annotations.extensions.ExtensionProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@JsonTypeName("user.statistics")
public class UserStatisticsData {
   public static final String USER_STATISTICS_TYPE = "user.statistics";
   @Schema(description = "User login history statistics.")
   private UserStatisticsData.HistoryData loginHistory = new UserStatisticsData.HistoryData();
   @Schema(description = "User self service statistics.")
   private UserStatisticsData.SelfServiceData selfService = new UserStatisticsData.SelfServiceData();

   @SuppressFBWarnings(justification = "generated code")
   public UserStatisticsData.HistoryData getLoginHistory() {
      return this.loginHistory;
   }

   @SuppressFBWarnings(justification = "generated code")
   public UserStatisticsData.SelfServiceData getSelfService() {
      return this.selfService;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setLoginHistory(UserStatisticsData.HistoryData loginHistory) {
      this.loginHistory = loginHistory;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setSelfService(UserStatisticsData.SelfServiceData selfService) {
      this.selfService = selfService;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   protected boolean canEqual(Object other) {
      return other instanceof UserStatisticsData;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "UserStatisticsData(loginHistory=" + this.getLoginHistory() + ", selfService=" + this.getSelfService() + ")";
   }

   public static class HistoryData {
      @Schema(description = "Number of total logins.")
      private int totalLogins;
      @Schema(description = "Number of failed logins.")
      private int failedLogins;
      @Schema(
         description = "Number of failed logins by authentication method. The key corresponds to the authentication method, the value to the number of failed logins with this authentication method. Currently, these counters are managed by the flow-based authentication only."
      )
      private Map<String, Integer> failedLoginsByAuthenticationMethod = new HashMap<>();
      @Schema(
         description = "Time of latest failed authentication attempt by authentication method. The key corresponds to the authentication method, the value to the time of the latest failed attempt with this authentication method. Currently, these values are managed by the flow-based authentication only.",
         extensions = @Extension(properties = @ExtensionProperty(name = "x-internal", value = "true"))
      )
      private Map<String, Date> latestFailedLoginAttemptsByAuthenticationMethod = new HashMap<>();
      @Schema(
         description = "Number of failed logins before the latest successful login.",
         extensions = @Extension(properties = @ExtensionProperty(name = "x-internal", value = "true"))
      )
      private int failedLoginsBeforeLatestSuccessfulLogin;
      @Schema(description = "Date of most recent successful login.")
      private Date latestSuccessfulLogin;
      @Schema(
         description = "Date of second most recent successful login.",
         extensions = @Extension(properties = @ExtensionProperty(name = "x-internal", value = "true"))
      )
      private Date secondLatestSuccessfulLogin;
      @Schema(description = "Date of most recent login attempt.")
      private Date latestLoginAttempt;
      @Schema(description = "Date of first login.")
      private Date firstLogin;
      @Schema(description = "Last Airlock WAF session ID.", extensions = @Extension(properties = @ExtensionProperty(name = "x-internal", value = "true")))
      private String lastAirlockSessionId;
      @Schema(
         description = "Date of last Airlock WAF session ID update.",
         extensions = @Extension(properties = @ExtensionProperty(name = "x-internal", value = "true"))
      )
      private Date lastAirlockSessionIdUpdate;

      @SuppressFBWarnings(justification = "generated code")
      public int getTotalLogins() {
         return this.totalLogins;
      }

      @SuppressFBWarnings(justification = "generated code")
      public int getFailedLogins() {
         return this.failedLogins;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Map<String, Integer> getFailedLoginsByAuthenticationMethod() {
         return this.failedLoginsByAuthenticationMethod;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Map<String, Date> getLatestFailedLoginAttemptsByAuthenticationMethod() {
         return this.latestFailedLoginAttemptsByAuthenticationMethod;
      }

      @SuppressFBWarnings(justification = "generated code")
      public int getFailedLoginsBeforeLatestSuccessfulLogin() {
         return this.failedLoginsBeforeLatestSuccessfulLogin;
      }

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

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

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      public void setTotalLogins(int totalLogins) {
         this.totalLogins = totalLogins;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setFailedLogins(int failedLogins) {
         this.failedLogins = failedLogins;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setFailedLoginsByAuthenticationMethod(Map<String, Integer> failedLoginsByAuthenticationMethod) {
         this.failedLoginsByAuthenticationMethod = failedLoginsByAuthenticationMethod;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setLatestFailedLoginAttemptsByAuthenticationMethod(Map<String, Date> latestFailedLoginAttemptsByAuthenticationMethod) {
         this.latestFailedLoginAttemptsByAuthenticationMethod = latestFailedLoginAttemptsByAuthenticationMethod;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setFailedLoginsBeforeLatestSuccessfulLogin(int failedLoginsBeforeLatestSuccessfulLogin) {
         this.failedLoginsBeforeLatestSuccessfulLogin = failedLoginsBeforeLatestSuccessfulLogin;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setLatestSuccessfulLogin(Date latestSuccessfulLogin) {
         this.latestSuccessfulLogin = latestSuccessfulLogin;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setSecondLatestSuccessfulLogin(Date secondLatestSuccessfulLogin) {
         this.secondLatestSuccessfulLogin = secondLatestSuccessfulLogin;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setLatestLoginAttempt(Date latestLoginAttempt) {
         this.latestLoginAttempt = latestLoginAttempt;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setFirstLogin(Date firstLogin) {
         this.firstLogin = firstLogin;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setLastAirlockSessionId(String lastAirlockSessionId) {
         this.lastAirlockSessionId = lastAirlockSessionId;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setLastAirlockSessionIdUpdate(Date lastAirlockSessionIdUpdate) {
         this.lastAirlockSessionIdUpdate = lastAirlockSessionIdUpdate;
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public boolean equals(Object o) {
         if (o == this) {
            return true;
         } else if (!(o instanceof UserStatisticsData.HistoryData other)) {
            return false;
         } else {
            if (!other.canEqual(this)) {
               return false;
            }

            if (this.totalLogins != other.totalLogins) {
               return false;
            }

            if (this.failedLogins != other.failedLogins) {
               return false;
            }

            if (this.failedLoginsBeforeLatestSuccessfulLogin != other.failedLoginsBeforeLatestSuccessfulLogin) {
               return false;
            }

            Object this$failedLoginsByAuthenticationMethod = this.failedLoginsByAuthenticationMethod;
            Object other$failedLoginsByAuthenticationMethod = other.failedLoginsByAuthenticationMethod;
            if (this$failedLoginsByAuthenticationMethod == null
               ? other$failedLoginsByAuthenticationMethod == null
               : this$failedLoginsByAuthenticationMethod.equals(other$failedLoginsByAuthenticationMethod)) {
               Object this$latestFailedLoginAttemptsByAuthenticationMethod = this.latestFailedLoginAttemptsByAuthenticationMethod;
               Object other$latestFailedLoginAttemptsByAuthenticationMethod = other.latestFailedLoginAttemptsByAuthenticationMethod;
               if (this$latestFailedLoginAttemptsByAuthenticationMethod == null
                  ? other$latestFailedLoginAttemptsByAuthenticationMethod == null
                  : this$latestFailedLoginAttemptsByAuthenticationMethod.equals(other$latestFailedLoginAttemptsByAuthenticationMethod)) {
                  Object this$latestSuccessfulLogin = this.latestSuccessfulLogin;
                  Object other$latestSuccessfulLogin = other.latestSuccessfulLogin;
                  if (this$latestSuccessfulLogin == null ? other$latestSuccessfulLogin == null : this$latestSuccessfulLogin.equals(other$latestSuccessfulLogin)
                     )
                   {
                     Object this$secondLatestSuccessfulLogin = this.secondLatestSuccessfulLogin;
                     Object other$secondLatestSuccessfulLogin = other.secondLatestSuccessfulLogin;
                     if (this$secondLatestSuccessfulLogin == null
                        ? other$secondLatestSuccessfulLogin == null
                        : this$secondLatestSuccessfulLogin.equals(other$secondLatestSuccessfulLogin)) {
                        Object this$latestLoginAttempt = this.latestLoginAttempt;
                        Object other$latestLoginAttempt = other.latestLoginAttempt;
                        if (this$latestLoginAttempt == null ? other$latestLoginAttempt == null : this$latestLoginAttempt.equals(other$latestLoginAttempt)) {
                           Object this$firstLogin = this.firstLogin;
                           Object other$firstLogin = other.firstLogin;
                           if (this$firstLogin == null ? other$firstLogin == null : this$firstLogin.equals(other$firstLogin)) {
                              Object this$lastAirlockSessionId = this.lastAirlockSessionId;
                              Object other$lastAirlockSessionId = other.lastAirlockSessionId;
                              if (this$lastAirlockSessionId == null
                                 ? other$lastAirlockSessionId == null
                                 : this$lastAirlockSessionId.equals(other$lastAirlockSessionId)) {
                                 Object this$lastAirlockSessionIdUpdate = this.lastAirlockSessionIdUpdate;
                                 Object other$lastAirlockSessionIdUpdate = other.lastAirlockSessionIdUpdate;
                                 return this$lastAirlockSessionIdUpdate == null
                                    ? other$lastAirlockSessionIdUpdate == null
                                    : this$lastAirlockSessionIdUpdate.equals(other$lastAirlockSessionIdUpdate);
                              } else {
                                 return false;
                              }
                           } else {
                              return false;
                           }
                        } else {
                           return false;
                        }
                     } else {
                        return false;
                     }
                  } else {
                     return false;
                  }
               } else {
                  return false;
               }
            } else {
               return false;
            }
         }
      }

      @SuppressFBWarnings(justification = "generated code")
      protected boolean canEqual(Object other) {
         return other instanceof UserStatisticsData.HistoryData;
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public int hashCode() {
         int PRIME = 59;
         int result = 1;
         result = result * 59 + this.totalLogins;
         result = result * 59 + this.failedLogins;
         result = result * 59 + this.failedLoginsBeforeLatestSuccessfulLogin;
         Object $failedLoginsByAuthenticationMethod = this.failedLoginsByAuthenticationMethod;
         result = result * 59 + ($failedLoginsByAuthenticationMethod == null ? 43 : $failedLoginsByAuthenticationMethod.hashCode());
         Object $latestFailedLoginAttemptsByAuthenticationMethod = this.latestFailedLoginAttemptsByAuthenticationMethod;
         result = result * 59 + ($latestFailedLoginAttemptsByAuthenticationMethod == null ? 43 : $latestFailedLoginAttemptsByAuthenticationMethod.hashCode());
         Object $latestSuccessfulLogin = this.latestSuccessfulLogin;
         result = result * 59 + ($latestSuccessfulLogin == null ? 43 : $latestSuccessfulLogin.hashCode());
         Object $secondLatestSuccessfulLogin = this.secondLatestSuccessfulLogin;
         result = result * 59 + ($secondLatestSuccessfulLogin == null ? 43 : $secondLatestSuccessfulLogin.hashCode());
         Object $latestLoginAttempt = this.latestLoginAttempt;
         result = result * 59 + ($latestLoginAttempt == null ? 43 : $latestLoginAttempt.hashCode());
         Object $firstLogin = this.firstLogin;
         result = result * 59 + ($firstLogin == null ? 43 : $firstLogin.hashCode());
         Object $lastAirlockSessionId = this.lastAirlockSessionId;
         result = result * 59 + ($lastAirlockSessionId == null ? 43 : $lastAirlockSessionId.hashCode());
         Object $lastAirlockSessionIdUpdate = this.lastAirlockSessionIdUpdate;
         return result * 59 + ($lastAirlockSessionIdUpdate == null ? 43 : $lastAirlockSessionIdUpdate.hashCode());
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "UserStatisticsData.HistoryData(totalLogins="
            + this.getTotalLogins()
            + ", failedLogins="
            + this.getFailedLogins()
            + ", failedLoginsByAuthenticationMethod="
            + this.getFailedLoginsByAuthenticationMethod()
            + ", latestFailedLoginAttemptsByAuthenticationMethod="
            + this.getLatestFailedLoginAttemptsByAuthenticationMethod()
            + ", failedLoginsBeforeLatestSuccessfulLogin="
            + this.getFailedLoginsBeforeLatestSuccessfulLogin()
            + ", latestSuccessfulLogin="
            + this.getLatestSuccessfulLogin()
            + ", secondLatestSuccessfulLogin="
            + this.getSecondLatestSuccessfulLogin()
            + ", latestLoginAttempt="
            + this.getLatestLoginAttempt()
            + ", firstLogin="
            + this.getFirstLogin()
            + ", lastAirlockSessionId="
            + this.getLastAirlockSessionId()
            + ", lastAirlockSessionIdUpdate="
            + this.getLastAirlockSessionIdUpdate()
            + ")";
      }
   }

   public static class SelfServiceData {
      @Schema(description = "Indicates whether the user registered himself.")
      private boolean selfRegistered;
      @Nullable
      @Schema(description = "Date of self-registration (optional).")
      private Date selfRegistrationDate;
      @Schema(description = "Number of unlock attempts.")
      private int unlockAttempts;
      @Nullable
      @Schema(description = "Date of most recent unlock attempt (optional).")
      private Date latestUnlockAttempt;

      @SuppressFBWarnings(justification = "generated code")
      public boolean isSelfRegistered() {
         return this.selfRegistered;
      }

      @Nullable
      @SuppressFBWarnings(justification = "generated code")
      public Date getSelfRegistrationDate() {
         return this.selfRegistrationDate;
      }

      @SuppressFBWarnings(justification = "generated code")
      public int getUnlockAttempts() {
         return this.unlockAttempts;
      }

      @Nullable
      @SuppressFBWarnings(justification = "generated code")
      public Date getLatestUnlockAttempt() {
         return this.latestUnlockAttempt;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setSelfRegistered(boolean selfRegistered) {
         this.selfRegistered = selfRegistered;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setSelfRegistrationDate(@Nullable Date selfRegistrationDate) {
         this.selfRegistrationDate = selfRegistrationDate;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setUnlockAttempts(int unlockAttempts) {
         this.unlockAttempts = unlockAttempts;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setLatestUnlockAttempt(@Nullable Date latestUnlockAttempt) {
         this.latestUnlockAttempt = latestUnlockAttempt;
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public boolean equals(Object o) {
         if (o == this) {
            return true;
         } else if (!(o instanceof UserStatisticsData.SelfServiceData other)) {
            return false;
         } else if (!other.canEqual(this)) {
            return false;
         } else if (this.selfRegistered != other.selfRegistered) {
            return false;
         } else if (this.unlockAttempts != other.unlockAttempts) {
            return false;
         } else {
            Object this$selfRegistrationDate = this.selfRegistrationDate;
            Object other$selfRegistrationDate = other.selfRegistrationDate;
            if (this$selfRegistrationDate == null ? other$selfRegistrationDate == null : this$selfRegistrationDate.equals(other$selfRegistrationDate)) {
               Object this$latestUnlockAttempt = this.latestUnlockAttempt;
               Object other$latestUnlockAttempt = other.latestUnlockAttempt;
               return this$latestUnlockAttempt == null ? other$latestUnlockAttempt == null : this$latestUnlockAttempt.equals(other$latestUnlockAttempt);
            } else {
               return false;
            }
         }
      }

      @SuppressFBWarnings(justification = "generated code")
      protected boolean canEqual(Object other) {
         return other instanceof UserStatisticsData.SelfServiceData;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "UserStatisticsData.SelfServiceData(selfRegistered="
            + this.isSelfRegistered()
            + ", selfRegistrationDate="
            + this.getSelfRegistrationDate()
            + ", unlockAttempts="
            + this.getUnlockAttempts()
            + ", latestUnlockAttempt="
            + this.getLatestUnlockAttempt()
            + ")";
      }
   }
}
