Class TmdbClientBuilder

java.lang.Object
dev.reuss.tmdb.TmdbClientBuilder

public final class TmdbClientBuilder extends Object
Builder for creating TmdbClient instances.

The builder configures authentication, the TMDB API base URL and default request settings such as language, region and timeouts.

At minimum, an access token or TmdbAuth instance must be provided before calling build().


 TmdbClient tmdb = TmdbClient.builder()
         .accessToken("your-access-token")
         .defaultLanguage(Languages.DE_DE)
         .build();
 
See Also:
  • Constructor Details

    • TmdbClientBuilder

      public TmdbClientBuilder()
  • Method Details

    • accessToken

      public TmdbClientBuilder accessToken(String accessToken)
      Sets the TMDB bearer access token.
      Parameters:
      accessToken - the TMDB bearer access token
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the access token is null, blank or empty
    • auth

      public TmdbClientBuilder auth(TmdbAuth auth)
      Sets the TMDB authentication configuration.
      Parameters:
      auth - the TMDB authentication configuration
      Returns:
      this builder
      Throws:
      NullPointerException - if auth is null
    • baseUrl

      public TmdbClientBuilder baseUrl(String baseUrl)
      Sets the TMDB API base URL.

      The default value is https://api.themoviedb.org/3. This is mainly useful for testing or custom deployments.

      Parameters:
      baseUrl - the TMDB API base URL
      Returns:
      this builder
    • defaultLanguage

      public TmdbClientBuilder defaultLanguage(Language defaultLanguage)
      Sets the default language for localized TMDB requests.

      The default value is Languages.EN_US.

      Parameters:
      defaultLanguage - the default language
      Returns:
      this builder
    • defaultRegion

      public TmdbClientBuilder defaultRegion(Region defaultRegion)
      Sets the default region for regional TMDB requests.

      The default region is optional and may be null. Not every TMDB request requires or supports a region.

      Parameters:
      defaultRegion - the default region, or null
      Returns:
      this builder
    • connectTimeout

      public TmdbClientBuilder connectTimeout(Duration connectTimeout)
      Sets the HTTP connection timeout.

      The default value is 5 seconds.

      Parameters:
      connectTimeout - the connection timeout
      Returns:
      this builder
    • requestTimeout

      public TmdbClientBuilder requestTimeout(Duration requestTimeout)
      Sets the overall HTTP request timeout.

      The default value is 10 seconds.

      Parameters:
      requestTimeout - the request timeout
      Returns:
      this builder
    • metricsRecorder

      public TmdbClientBuilder metricsRecorder(TmdbMetricsRecorder metricsRecorder)
      Sets the metrics recorder used to observe TMDB HTTP requests.

      The default recorder is a no-op implementation.

      Parameters:
      metricsRecorder - the metrics recorder
      Returns:
      this builder
      Throws:
      NullPointerException - if metricsRecorder is null
    • build

      public TmdbClient build()
      Builds a new TmdbClient.
      Returns:
      a new TMDB client instance
      Throws:
      NullPointerException - if required configuration values are missing
      IllegalArgumentException - if configuration values are invalid