类 DocumentMetadata.Builder

java.lang.Object
io.agentscope.core.rag.model.DocumentMetadata.Builder
封闭类:
DocumentMetadata

public static class DocumentMetadata.Builder extends Object
Builder for constructing DocumentMetadata instances with fluent API.

This builder provides a convenient way to create DocumentMetadata objects, especially when working with custom payload fields. All fields can be set independently, and the builder validates required fields when build() is called.

  • 方法详细资料

    • content

      public DocumentMetadata.Builder content(ContentBlock content)
      Sets the content block.
      参数:
      content - the content block (text, image, video, etc.)
      返回:
      this builder for method chaining
    • docId

      public DocumentMetadata.Builder docId(String docId)
      Sets the document ID.
      参数:
      docId - the document ID
      返回:
      this builder for method chaining
    • chunkId

      public DocumentMetadata.Builder chunkId(String chunkId)
      Sets the chunk ID.
      参数:
      chunkId - the chunk ID within the document
      返回:
      this builder for method chaining
    • payload

      public DocumentMetadata.Builder payload(Map<String,Object> payload)
      Sets the entire payload map.

      This replaces any previously set payload. The map is copied to prevent external modifications.

      参数:
      payload - the custom metadata fields (can be null)
      返回:
      this builder for method chaining
    • addPayload

      public DocumentMetadata.Builder addPayload(String key, Object value)
      Adds a single payload field.

      This method allows adding payload fields one at a time. If the payload map doesn't exist yet, it will be created automatically.

      参数:
      key - the payload key
      value - the payload value
      返回:
      this builder for method chaining
      抛出:
      NullPointerException - if key is null
    • build

      public DocumentMetadata build()
      Builds a new DocumentMetadata instance with the configured values.
      返回:
      a new DocumentMetadata instance
      抛出:
      IllegalArgumentException - if required fields (content, docId, chunkId) are null