package com.airlock.iam.common.infrastructure.i18n;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.annotation.Nullable;
import java.nio.file.Path;
import java.util.Optional;

public final class UiResourceIdentifier {
   private final Path resource;
   @Nullable
   private final String resourceSetName;

   private UiResourceIdentifier(Path resourceFilename, @Nullable String resourceSetName) {
      this.resource = resourceFilename;
      this.resourceSetName = resourceSetName;
   }

   public static UiResourceIdentifier withResourceSet(Path resource, String resourceSetName) {
      return new UiResourceIdentifier(resource, resourceSetName);
   }

   public static UiResourceIdentifier withoutResourceSet(Path resource) {
      return new UiResourceIdentifier(resource, null);
   }

   public String getResource() {
      return this.resource.toString();
   }

   public Optional<String> getResourceSetName() {
      return Optional.ofNullable(this.resourceSetName);
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "UiResourceIdentifier(resource=" + this.getResource() + ", resourceSetName=" + this.getResourceSetName() + ")";
   }
}
