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 aDefaultContent
record class.DefaultContent
(String text) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares thisContent
with another object for equality.int
hashCode()
Computes the hash code for thisContent
.metadata()
Returns the value of themetadata
record component.Returns the value of thetextSegment
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
DefaultContent
Creates an instance of aDefaultContent
record class.- Parameters:
textSegment
- the value for thetextSegment
record componentmetadata
- the value for themetadata
record component
-
DefaultContent
-
DefaultContent
-
-
Method Details
-
equals
Compares thisContent
with another object for equality.
Themetadata
field 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
.
Themetadata
field is excluded from the hash code calculation. This ensures that two logically identicalContent
objects 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 thetextSegment
record component.- Specified by:
textSegment
in interfaceContent
- Returns:
- the value of the
textSegment
record component
-
metadata
Returns the value of themetadata
record component.
-