package com.airlock.iam.oauth2.api.domain.model.tokenexchange;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
import java.util.Collection;
import java.util.List;
import lombok.NonNull;

public final class OAuth2TokenExchangeTargetResource {
   @NonNull
   private final URI resource;

   public static OAuth2TokenExchangeTargetResource resource(URI resource) {
      return new OAuth2TokenExchangeTargetResource(resource);
   }

   public static List<OAuth2TokenExchangeTargetResource> convertToResources(Collection<URI> scopes) {
      return scopes.stream().map(OAuth2TokenExchangeTargetResource::resource).toList();
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public URI resource() {
      return this.resource;
   }

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

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

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

   @SuppressFBWarnings(justification = "generated code")
   private OAuth2TokenExchangeTargetResource(@NonNull URI resource) {
      if (resource == null) {
         throw new NullPointerException("resource is marked non-null but is null");
      }

      this.resource = resource;
   }
}
