Record Class TmdbRequest

java.lang.Object
java.lang.Record
dev.reuss.tmdb.core.http.TmdbRequest
Record Components:
path - the request path relative to the TMDB API base URL
queryParams - the request query parameters
All Implemented Interfaces:
Serializable

public record TmdbRequest(String path, Map<String,String> queryParams) extends Record implements Serializable
Represents a TMDB HTTP request.

A request consists of a path relative to the configured TMDB base URL and optional query parameters. Paths must start with /, for example /configuration or /movie/550.

This record does not contain the HTTP method explicitly yet, because the current SDK core only supports GET requests.

See Also:
  • Constructor Details

    • TmdbRequest

      public TmdbRequest(String path)
      Creates a request without query parameters.
      Parameters:
      path - the request path relative to the TMDB API base URL
    • TmdbRequest

      public TmdbRequest(String path, Map<String,String> queryParams)
      Creates a new TMDB request.
      Throws:
      IllegalArgumentException - if path is null, blank, empty or does not start with /
  • Method Details

    • get

      public static TmdbRequest get(String path)
      Creates a GET request without query parameters.
      Parameters:
      path - the request path relative to the TMDB API base URL
      Returns:
      a new TMDB request
    • get

      public static TmdbRequest get(String path, QueryParams queryParams)
      Creates a GET request with query parameters.
      Parameters:
      path - the request path relative to the TMDB API base URL
      queryParams - the query parameters to include
      Returns:
      a new TMDB request
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • queryParams

      public Map<String,String> queryParams()
      Returns the value of the queryParams record component.
      Returns:
      the value of the queryParams record component