package com.airlock.iam.application.parameters.domain.model;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;

public final class LogParameters {
   private final String level;
   private final String label;
   private final LogParameters.MainLogParameters main;
   private final LogParameters.StructuredLogParameters structured;
   private final LogParameters.AuditLogParameters audit;

   public LogParameters(
      String level,
      String label,
      LogParameters.MainLogParameters main,
      LogParameters.StructuredLogParameters structured,
      LogParameters.AuditLogParameters audit
   ) {
      this.level = Objects.requireNonNull(level);
      this.label = label;
      this.main = Objects.requireNonNull(main);
      this.structured = Objects.requireNonNull(structured);
      this.audit = audit;
   }

   public Optional<LogParameters.AuditLogParameters> audit() {
      return Optional.ofNullable(this.audit);
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public LogParameters.MainLogParameters main() {
      return this.main;
   }

   @SuppressFBWarnings(justification = "generated code")
   public LogParameters.StructuredLogParameters structured() {
      return this.structured;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof LogParameters other)) {
         return false;
      } else {
         Object this$level = this.level;
         Object other$level = other.level;
         if (this$level == null ? other$level == null : this$level.equals(other$level)) {
            Object this$label = this.label;
            Object other$label = other.label;
            if (this$label == null ? other$label == null : this$label.equals(other$label)) {
               Object this$main = this.main;
               Object other$main = other.main;
               if (this$main == null ? other$main == null : this$main.equals(other$main)) {
                  Object this$structured = this.structured;
                  Object other$structured = other.structured;
                  if (this$structured == null ? other$structured == null : this$structured.equals(other$structured)) {
                     Object this$audit = this.audit;
                     Object other$audit = other.audit;
                     return this$audit == null ? other$audit == null : this$audit.equals(other$audit);
                  } 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 $level = this.level;
      result = result * 59 + ($level == null ? 43 : $level.hashCode());
      Object $label = this.label;
      result = result * 59 + ($label == null ? 43 : $label.hashCode());
      Object $main = this.main;
      result = result * 59 + ($main == null ? 43 : $main.hashCode());
      Object $structured = this.structured;
      result = result * 59 + ($structured == null ? 43 : $structured.hashCode());
      Object $audit = this.audit;
      return result * 59 + ($audit == null ? 43 : $audit.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "LogParameters(level="
         + this.level()
         + ", label="
         + this.label()
         + ", main="
         + this.main()
         + ", structured="
         + this.structured()
         + ", audit="
         + this.audit()
         + ")";
   }

   public static final class AuditLogParameters {
      private final Path signingConfig;

      public AuditLogParameters(Path signingConfig) {
         this.signingConfig = Objects.requireNonNull(signingConfig);
      }

      @SuppressFBWarnings(justification = "generated code")
      public Path signingConfig() {
         return this.signingConfig;
      }

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

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "LogParameters.AuditLogParameters(signingConfig=" + this.signingConfig() + ")";
      }
   }

   public static final class MainLogParameters {
      private final Path directory;
      private final int rotateMaxDays;
      private final String pattern;

      public MainLogParameters(Path directory, int rotateMaxDays, String pattern) {
         this.directory = Objects.requireNonNull(directory);
         this.rotateMaxDays = rotateMaxDays;
         this.pattern = Objects.requireNonNull(pattern);
      }

      @SuppressFBWarnings(justification = "generated code")
      public Path directory() {
         return this.directory;
      }

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "LogParameters.MainLogParameters(directory="
            + this.directory()
            + ", rotateMaxDays="
            + this.rotateMaxDays()
            + ", pattern="
            + this.pattern()
            + ")";
      }
   }

   public static final class StructuredLogParameters {
      private final Path fileDirectory;
      private final URI elasticsearchUrl;

      public StructuredLogParameters(Path fileDirectory, URI elasticsearchUrl) {
         this.fileDirectory = Objects.requireNonNull(fileDirectory);
         this.elasticsearchUrl = elasticsearchUrl;
      }

      public Optional<URI> elasticsearchUrl() {
         return Optional.ofNullable(this.elasticsearchUrl);
      }

      @SuppressFBWarnings(justification = "generated code")
      public Path fileDirectory() {
         return this.fileDirectory;
      }

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

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "LogParameters.StructuredLogParameters(fileDirectory=" + this.fileDirectory() + ", elasticsearchUrl=" + this.elasticsearchUrl() + ")";
      }
   }
}
