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

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

public abstract class Log4jConfig {
   public abstract Optional<ParameterVariableSpec> getVariable();

   public abstract Optional<Path> getPath();

   public static Log4jConfig resolvedWith(Path path) {
      return new Log4jConfig.Resolved(path);
   }

   public static Log4jConfig referencedBy(ParameterVariableSpec variable) {
      return new Log4jConfig.Referenced(variable);
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int result = 1;
      return 1;
   }

   private static final class Referenced extends Log4jConfig {
      private final ParameterVariableSpec expression;

      public Referenced(ParameterVariableSpec expression) {
         this.expression = Objects.requireNonNull(expression);
      }

      @Override
      public Optional<ParameterVariableSpec> getVariable() {
         return Optional.of(this.expression);
      }

      @Override
      public Optional<Path> getPath() {
         return Optional.empty();
      }

      @Override
      public String toString() {
         return this.expression.expression();
      }

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

            if (!super.equals(o)) {
               return false;
            }

            Object this$expression = this.expression;
            Object other$expression = other.expression;
            return this$expression == null ? other$expression == null : this$expression.equals(other$expression);
         }
      }

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

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

   private static final class Resolved extends Log4jConfig {
      private final Path path;

      public Resolved(Path path) {
         this.path = Objects.requireNonNull(path);
      }

      @Override
      public Optional<ParameterVariableSpec> getVariable() {
         return Optional.empty();
      }

      @Override
      public Optional<Path> getPath() {
         return Optional.of(this.path);
      }

      @Override
      public String toString() {
         return this.path.toString();
      }

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

            if (!super.equals(o)) {
               return false;
            }

            Object this$path = this.path;
            Object other$path = other.path;
            return this$path == null ? other$path == null : this$path.equals(other$path);
         }
      }

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

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