package com.airlock.iam.admin.domain.model.logs;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.nio.charset.Charset;
import lombok.NonNull;

public record LogFileInfo(@NonNull String key, String filePath, Charset charset) {
   public LogFileInfo {
      if (key == null) {
         throw new NullPointerException("key is marked non-null but is null");
      }

      if (key.contains("\n")) {
         throw new IllegalArgumentException("Key must not contain new line characters");
      }
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public static class LogFileInfoBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String key;
      @SuppressFBWarnings(justification = "generated code")
      private String filePath;
      @SuppressFBWarnings(justification = "generated code")
      private Charset charset;

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

      @SuppressFBWarnings(justification = "generated code")
      public LogFileInfo.LogFileInfoBuilder key(@NonNull String key) {
         if (key == null) {
            throw new NullPointerException("key is marked non-null but is null");
         }

         this.key = key;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public LogFileInfo.LogFileInfoBuilder filePath(String filePath) {
         this.filePath = filePath;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public LogFileInfo.LogFileInfoBuilder charset(Charset charset) {
         this.charset = charset;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public LogFileInfo build() {
         return new LogFileInfo(this.key, this.filePath, this.charset);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "LogFileInfo.LogFileInfoBuilder(key=" + this.key + ", filePath=" + this.filePath + ", charset=" + this.charset + ")";
      }
   }
}
