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

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;

public final class DeviceTokenInfo {
   private final String id;
   private final String serial;
   private final String label;
   private final Date validTo;
   private final Date validFrom;
   private final Date latestUsageDate;
   private final Date activationDate;
   private final Date generationDate;
   private final int totalUsages;
   private final boolean active;

   public static DeviceTokenInfo deviceTokenInfo(DeviceToken token) {
      return new DeviceTokenInfo(
         token.getId(),
         token.getSerial(),
         token.getLabel(),
         token.getValidTo(),
         token.getValidFrom(),
         token.getLatestUsageDate(),
         token.getActivationDate(),
         token.getGenerationDate(),
         token.getTotalUsages(),
         token.isEnabled()
      );
   }

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

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

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

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

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

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

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

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

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

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

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

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

         Object this$id = this.id;
         Object other$id = other.id;
         if (this$id == null ? other$id == null : this$id.equals(other$id)) {
            Object this$serial = this.serial;
            Object other$serial = other.serial;
            if (this$serial == null ? other$serial == null : this$serial.equals(other$serial)) {
               Object this$label = this.label;
               Object other$label = other.label;
               if (this$label == null ? other$label == null : this$label.equals(other$label)) {
                  Object this$validTo = this.validTo;
                  Object other$validTo = other.validTo;
                  if (this$validTo == null ? other$validTo == null : this$validTo.equals(other$validTo)) {
                     Object this$validFrom = this.validFrom;
                     Object other$validFrom = other.validFrom;
                     if (this$validFrom == null ? other$validFrom == null : this$validFrom.equals(other$validFrom)) {
                        Object this$latestUsageDate = this.latestUsageDate;
                        Object other$latestUsageDate = other.latestUsageDate;
                        if (this$latestUsageDate == null ? other$latestUsageDate == null : this$latestUsageDate.equals(other$latestUsageDate)) {
                           Object this$activationDate = this.activationDate;
                           Object other$activationDate = other.activationDate;
                           if (this$activationDate == null ? other$activationDate == null : this$activationDate.equals(other$activationDate)) {
                              Object this$generationDate = this.generationDate;
                              Object other$generationDate = other.generationDate;
                              return this$generationDate == null ? other$generationDate == null : this$generationDate.equals(other$generationDate);
                           } 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")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      result = result * 59 + this.totalUsages;
      result = result * 59 + (this.active ? 79 : 97);
      Object $id = this.id;
      result = result * 59 + ($id == null ? 43 : $id.hashCode());
      Object $serial = this.serial;
      result = result * 59 + ($serial == null ? 43 : $serial.hashCode());
      Object $label = this.label;
      result = result * 59 + ($label == null ? 43 : $label.hashCode());
      Object $validTo = this.validTo;
      result = result * 59 + ($validTo == null ? 43 : $validTo.hashCode());
      Object $validFrom = this.validFrom;
      result = result * 59 + ($validFrom == null ? 43 : $validFrom.hashCode());
      Object $latestUsageDate = this.latestUsageDate;
      result = result * 59 + ($latestUsageDate == null ? 43 : $latestUsageDate.hashCode());
      Object $activationDate = this.activationDate;
      result = result * 59 + ($activationDate == null ? 43 : $activationDate.hashCode());
      Object $generationDate = this.generationDate;
      return result * 59 + ($generationDate == null ? 43 : $generationDate.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "DeviceTokenInfo(id="
         + this.getId()
         + ", serial="
         + this.getSerial()
         + ", label="
         + this.getLabel()
         + ", validTo="
         + this.getValidTo()
         + ", validFrom="
         + this.getValidFrom()
         + ", latestUsageDate="
         + this.getLatestUsageDate()
         + ", activationDate="
         + this.getActivationDate()
         + ", generationDate="
         + this.getGenerationDate()
         + ", totalUsages="
         + this.getTotalUsages()
         + ", active="
         + this.isActive()
         + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   private DeviceTokenInfo(
      String id,
      String serial,
      String label,
      Date validTo,
      Date validFrom,
      Date latestUsageDate,
      Date activationDate,
      Date generationDate,
      int totalUsages,
      boolean active
   ) {
      this.id = id;
      this.serial = serial;
      this.label = label;
      this.validTo = validTo;
      this.validFrom = validFrom;
      this.latestUsageDate = latestUsageDate;
      this.activationDate = activationDate;
      this.generationDate = generationDate;
      this.totalUsages = totalUsages;
      this.active = active;
   }
}
