Package org.springframework.ai.model
Record Class SimpleApiKey
java.lang.Object
java.lang.Record
org.springframework.ai.model.SimpleApiKey
- All Implemented Interfaces:
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 -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.getValue()
Returns an api key to use for a making request.final int
hashCode()
Returns a hash code value for this object.toString()
Returns a string representation of this record class.value()
Returns the value of thevalue
record component.
-
Constructor Details
-
SimpleApiKey
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
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. -
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
value
Returns the value of thevalue
record component.- Returns:
- the value of the
value
record component
-