类 DocumentMetadata.Builder
java.lang.Object
io.agentscope.core.rag.model.DocumentMetadata.Builder
- 封闭类:
DocumentMetadata
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.
-
方法概要
修饰符和类型方法说明addPayload(String key, Object value) Adds a single payload field.build()Builds a new DocumentMetadata instance with the configured values.Sets the chunk ID.content(ContentBlock content) Sets the content block.Sets the document ID.Sets the entire payload map.
-
方法详细资料
-
content
Sets the content block.- 参数:
content- the content block (text, image, video, etc.)- 返回:
- this builder for method chaining
-
docId
Sets the document ID.- 参数:
docId- the document ID- 返回:
- this builder for method chaining
-
chunkId
Sets the chunk ID.- 参数:
chunkId- the chunk ID within the document- 返回:
- this builder for method chaining
-
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
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 keyvalue- the payload value- 返回:
- this builder for method chaining
- 抛出:
NullPointerException- if key is null
-
build
Builds a new DocumentMetadata instance with the configured values.- 返回:
- a new DocumentMetadata instance
- 抛出:
IllegalArgumentException- if required fields (content, docId, chunkId) are null
-