Record Class TmdbAuth

java.lang.Object
java.lang.Record
dev.reuss.tmdb.core.auth.TmdbAuth
Record Components:
accessToken - TMDB bearer access token
All Implemented Interfaces:
Serializable

public record TmdbAuth(String accessToken) extends Record implements Serializable
Represents TMDB API authentication.

TMDB API requests are authenticated with a bearer access token. This value object stores the raw access token and can create the corresponding HTTP Authorization header value.

The access token is intentionally masked in toString() to avoid accidentally exposing credentials in logs or debug output.

See Also:
  • Constructor Details

    • TmdbAuth

      public TmdbAuth(String accessToken)
      Creates a new TMDB authentication value.
      Parameters:
      accessToken - the TMDB bearer access token
      Throws:
      IllegalArgumentException - if the access token is null, blank or empty
  • Method Details

    • bearerToken

      public static TmdbAuth bearerToken(String accessToken)
      Creates authentication from a TMDB bearer access token.
      Parameters:
      accessToken - the TMDB bearer access token
      Returns:
      a new TMDB authentication value
      Throws:
      IllegalArgumentException - if the access token is null, blank or empty
    • authorizationHeaderValue

      public String authorizationHeaderValue()
      Returns the value for the HTTP Authorization header.
      Returns:
      the authorization header value in the format Bearer <token>
    • toString

      public String toString()
      Returns a masked string representation to avoid leaking the access token.
      Specified by:
      toString in class Record
      Returns:
      a masked string representation
    • 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.
    • accessToken

      public String accessToken()
      Returns the value of the accessToken record component.
      Returns:
      the value of the accessToken record component