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

import com.fasterxml.jackson.annotation.JsonTypeName;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;

@JsonTypeName("logs")
public final class LogsData {
   public static final String LOGS_TYPE = "logs";
   @ArraySchema(arraySchema = @Schema(description = "The log lines."))
   private List<LogsData.LogData> logLines;

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

   @SuppressFBWarnings(justification = "generated code")
   public List<LogsData.LogData> getLogLines() {
      return this.logLines;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setLogLines(List<LogsData.LogData> logLines) {
      this.logLines = logLines;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "LogsData(logLines=" + this.getLogLines() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public LogsData(List<LogsData.LogData> logLines) {
      this.logLines = logLines;
   }

   public static final class LogData {
      @Schema(description = "The date when the log was created.")
      private Date timestamp;
      @Schema(description = "The log level.")
      private String level;
      @Schema(description = "The HTTP session ID that the log is related to. '000000000000000000' if the log is not related to any session ID.")
      private String sessionId;
      @Schema(description = "The HTTP request ID that the log is related to. '000000000000000000' if the log is not related to any request ID.")
      private String requestId;
      @Schema(description = "The sequence number of the log.")
      private String sequenceNumber;
      @ArraySchema(arraySchema = @Schema(description = "The message lines that the log consists of."))
      private List<String> messageLines;
      @Schema(description = "The identifier of the configuration context in which the log was created.")
      private String configContextIdentifier;
      @Nullable
      @Schema(description = "The client's IP address.")
      private String clientIp;
      @Nullable
      @Schema(description = "Information about the verification of the signature on the log.")
      private String signatureVerification;
      @Schema(description = "True if the log is pre-formatted (e.g. ASCII art), false otherwise.")
      private boolean preformatted;

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

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      public List<String> getMessageLines() {
         return this.messageLines;
      }

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

      @Nullable
      @SuppressFBWarnings(justification = "generated code")
      public String getClientIp() {
         return this.clientIp;
      }

      @Nullable
      @SuppressFBWarnings(justification = "generated code")
      public String getSignatureVerification() {
         return this.signatureVerification;
      }

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

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

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      public void setMessageLines(List<String> messageLines) {
         this.messageLines = messageLines;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      public void setClientIp(@Nullable String clientIp) {
         this.clientIp = clientIp;
      }

      @SuppressFBWarnings(justification = "generated code")
      public void setSignatureVerification(@Nullable String signatureVerification) {
         this.signatureVerification = signatureVerification;
      }

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

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

            Object this$timestamp = this.timestamp;
            Object other$timestamp = other.timestamp;
            if (this$timestamp == null ? other$timestamp == null : this$timestamp.equals(other$timestamp)) {
               Object this$level = this.level;
               Object other$level = other.level;
               if (this$level == null ? other$level == null : this$level.equals(other$level)) {
                  Object this$sessionId = this.sessionId;
                  Object other$sessionId = other.sessionId;
                  if (this$sessionId == null ? other$sessionId == null : this$sessionId.equals(other$sessionId)) {
                     Object this$requestId = this.requestId;
                     Object other$requestId = other.requestId;
                     if (this$requestId == null ? other$requestId == null : this$requestId.equals(other$requestId)) {
                        Object this$sequenceNumber = this.sequenceNumber;
                        Object other$sequenceNumber = other.sequenceNumber;
                        if (this$sequenceNumber == null ? other$sequenceNumber == null : this$sequenceNumber.equals(other$sequenceNumber)) {
                           Object this$messageLines = this.messageLines;
                           Object other$messageLines = other.messageLines;
                           if (this$messageLines == null ? other$messageLines == null : this$messageLines.equals(other$messageLines)) {
                              Object this$configContextIdentifier = this.configContextIdentifier;
                              Object other$configContextIdentifier = other.configContextIdentifier;
                              if (this$configContextIdentifier == null
                                 ? other$configContextIdentifier == null
                                 : this$configContextIdentifier.equals(other$configContextIdentifier)) {
                                 Object this$clientIp = this.clientIp;
                                 Object other$clientIp = other.clientIp;
                                 if (this$clientIp == null ? other$clientIp == null : this$clientIp.equals(other$clientIp)) {
                                    Object this$signatureVerification = this.signatureVerification;
                                    Object other$signatureVerification = other.signatureVerification;
                                    return this$signatureVerification == null
                                       ? other$signatureVerification == null
                                       : this$signatureVerification.equals(other$signatureVerification);
                                 } else {
                                    return false;
                                 }
                              } 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.preformatted ? 79 : 97);
         Object $timestamp = this.timestamp;
         result = result * 59 + ($timestamp == null ? 43 : $timestamp.hashCode());
         Object $level = this.level;
         result = result * 59 + ($level == null ? 43 : $level.hashCode());
         Object $sessionId = this.sessionId;
         result = result * 59 + ($sessionId == null ? 43 : $sessionId.hashCode());
         Object $requestId = this.requestId;
         result = result * 59 + ($requestId == null ? 43 : $requestId.hashCode());
         Object $sequenceNumber = this.sequenceNumber;
         result = result * 59 + ($sequenceNumber == null ? 43 : $sequenceNumber.hashCode());
         Object $messageLines = this.messageLines;
         result = result * 59 + ($messageLines == null ? 43 : $messageLines.hashCode());
         Object $configContextIdentifier = this.configContextIdentifier;
         result = result * 59 + ($configContextIdentifier == null ? 43 : $configContextIdentifier.hashCode());
         Object $clientIp = this.clientIp;
         result = result * 59 + ($clientIp == null ? 43 : $clientIp.hashCode());
         Object $signatureVerification = this.signatureVerification;
         return result * 59 + ($signatureVerification == null ? 43 : $signatureVerification.hashCode());
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "LogsData.LogData(timestamp="
            + this.getTimestamp()
            + ", level="
            + this.getLevel()
            + ", sessionId="
            + this.getSessionId()
            + ", requestId="
            + this.getRequestId()
            + ", sequenceNumber="
            + this.getSequenceNumber()
            + ", messageLines="
            + this.getMessageLines()
            + ", configContextIdentifier="
            + this.getConfigContextIdentifier()
            + ", clientIp="
            + this.getClientIp()
            + ", signatureVerification="
            + this.getSignatureVerification()
            + ", preformatted="
            + this.isPreformatted()
            + ")";
      }

      @SuppressFBWarnings(justification = "generated code")
      public LogData(
         Date timestamp,
         String level,
         String sessionId,
         String requestId,
         String sequenceNumber,
         List<String> messageLines,
         String configContextIdentifier,
         @Nullable String clientIp,
         @Nullable String signatureVerification,
         boolean preformatted
      ) {
         this.timestamp = timestamp;
         this.level = level;
         this.sessionId = sessionId;
         this.requestId = requestId;
         this.sequenceNumber = sequenceNumber;
         this.messageLines = messageLines;
         this.configContextIdentifier = configContextIdentifier;
         this.clientIp = clientIp;
         this.signatureVerification = signatureVerification;
         this.preformatted = preformatted;
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class LogsDataBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private ArrayList<LogsData.LogData> logLines;

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

      @SuppressFBWarnings(justification = "generated code")
      public LogsData.LogsDataBuilder logLine(LogsData.LogData logLine) {
         if (this.logLines == null) {
            this.logLines = new ArrayList<>();
         }

         this.logLines.add(logLine);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public LogsData.LogsDataBuilder logLines(Collection<? extends LogsData.LogData> logLines) {
         if (logLines == null) {
            throw new NullPointerException("logLines cannot be null");
         }

         if (this.logLines == null) {
            this.logLines = new ArrayList<>();
         }

         this.logLines.addAll(logLines);
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public LogsData.LogsDataBuilder clearLogLines() {
         if (this.logLines != null) {
            this.logLines.clear();
         }

         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public LogsData build() {
         return new LogsData(switch (this.logLines == null ? 0 : this.logLines.size()) {
            case 0 -> Collections.emptyList();
            case 1 -> Collections.singletonList(this.logLines.get(0));
            default -> Collections.unmodifiableList(new ArrayList<>(this.logLines));
         });
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "LogsData.LogsDataBuilder(logLines=" + this.logLines + ")";
      }
   }
}
