Record Class EmbeddingParameter<T>

java.lang.Object
java.lang.Record
dev.langchain4j.model.embedding.request.EmbeddingParameter<T>
Type Parameters:
T - the type of the value this parameter holds.
Record Components:
name - a globally unique, human-readable name for this parameter (e.g. "dimensions").
type - the type of the value this parameter holds.

@Experimental public record EmbeddingParameter<T>(String name, Class<T> type) extends Record
A typed, stable identifier for a single EmbeddingRequestParameters value.

Parameters are identified by tokens (rather than plain strings) so that:

  • the value type is known at compile time (see type());
  • provider modules can declare their own parameters (e.g. an OpenAI USER token) without touching langchain4j-core;
  • an EmbeddingModel can declare exactly which parameters it honors via EmbeddingModel.supportedParameters(). Any parameter present in a request but absent from that set is rejected, so a newly introduced parameter is opt-in: an implementation that has not explicitly declared support for it will fail fast instead of silently ignoring it.
Two tokens are considered equal when their name() is equal; the name is therefore the globally unique identity of a parameter and must not collide across providers. equals(Object) and hashCode() intentionally key on name only, ignoring type().
Since:
1.18.0
  • Constructor Details

    • EmbeddingParameter

      public EmbeddingParameter(String name, Class<T> type)
      Creates an instance of a EmbeddingParameter record class.
      Parameters:
      name - the value for the name record component
      type - the value for the type record component
  • Method Details

    • cast

      public T cast(Object value)
      Casts the given value to this parameter's type().
      Parameters:
      value - the value to cast, may be null.
      Returns:
      the value, typed.
    • equals

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

      public 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
    • 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
    • name

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

      public Class<T> type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component