Package dev.langchain4j.rag.content
Record Class DefaultContent
java.lang.Object
java.lang.Record
dev.langchain4j.rag.content.DefaultContent
- All Implemented Interfaces:
Content
public record DefaultContent(TextSegment textSegment, Map<ContentMetadata,Object> metadata)
extends Record
implements Content
A default implementation of a
The class includes optional metadata which can store additional information about the content. This metadata is supplementary and is intentionally excluded from equality and hash calculations. See
Content.
The class includes optional metadata which can store additional information about the content. This metadata is supplementary and is intentionally excluded from equality and hash calculations. See
equals(Object) and hashCode() for details.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultContent(TextSegment textSegment) DefaultContent(TextSegment textSegment, Map<ContentMetadata, Object> metadata) Creates an instance of aDefaultContentrecord class.DefaultContent(String text) -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares thisContentwith another object for equality.inthashCode()Computes the hash code for thisContent.metadata()Returns the value of themetadatarecord component.Returns the value of thetextSegmentrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
DefaultContent
Creates an instance of aDefaultContentrecord class.- Parameters:
textSegment- the value for thetextSegmentrecord componentmetadata- the value for themetadatarecord component
-
DefaultContent
-
DefaultContent
-
-
Method Details
-
equals
Compares thisContentwith another object for equality.
Themetadatafield is intentionally excluded from the equality check. Metadata is considered supplementary information and does not contribute to the core identity of theContent. -
hashCode
public int hashCode()Computes the hash code for thisContent.
Themetadatafield is excluded from the hash code calculation. This ensures that two logically identicalContentobjects with differing metadata produce the same hash code, maintaining consistent behavior in hash-based collections. -
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. -
textSegment
Returns the value of thetextSegmentrecord component.- Specified by:
textSegmentin interfaceContent- Returns:
- the value of the
textSegmentrecord component
-
metadata
Returns the value of themetadatarecord component.
-