Record Class SimpleApiKey

java.lang.Object
java.lang.Record
org.springframework.ai.model.SimpleApiKey
All Implemented Interfaces:
ApiKey

public record SimpleApiKey(String value) extends Record implements ApiKey
A simple implementation of ApiKey that holds an immutable API key value. This implementation is suitable for cases where the API key is static and does not need to be refreshed or rotated.
Since:
1.0.0
Author:
Adib Saikali, Christian Tzolov
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new SimpleApiKey.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns an api key to use for a making request.
    final int
    Returns a hash code value for this object.
    Returns a string representation of this record class.
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SimpleApiKey

      public SimpleApiKey(String value)
      Create a new SimpleApiKey.
      Parameters:
      value - the API key value, must not be null or empty
      Throws:
      IllegalArgumentException - if value is null or empty
  • Method Details

    • getValue

      public String getValue()
      Description copied from interface: ApiKey
      Returns an api key to use for a making request. Users of this method should NOT cache the returned api key, instead call this method whenever you need an api key. Implementors of this method MUST ensure that the returned key is not expired.
      Specified by:
      getValue in interface ApiKey
      Returns:
      the current value of the api key
    • toString

      public 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.
    • value

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