Class DefaultContent

java.lang.Object
dev.langchain4j.rag.content.DefaultContent
All Implemented Interfaces:
Content

public class DefaultContent extends Object implements Content
A default implementation of a 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 Details

  • Method Details

    • textSegment

      public TextSegment textSegment()
      Specified by:
      textSegment in interface Content
    • metadata

      public Map<ContentMetadata,Object> metadata()
      Specified by:
      metadata in interface Content
    • equals

      public boolean equals(Object o)
      Compares this Content with another object for equality.
      The metadata field is intentionally excluded from the equality check. Metadata is considered supplementary information and does not contribute to the core identity of the Content.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Computes the hash code for this Content.
      The metadata field is excluded from the hash code calculation. This ensures that two logically identical Content objects with differing metadata produce the same hash code, maintaining consistent behavior in hash-based collections.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object