Record Class Metadata

java.lang.Object
java.lang.Record
cloud.opencode.base.pdf.document.Metadata
Record Components:
title - document title | 文档标题
author - document author | 文档作者
subject - document subject | 文档主题
keywords - document keywords | 文档关键词
creator - creating application | 创建应用程序
producer - PDF producer | PDF 生成器
creationDate - creation date | 创建日期
modDate - modification date | 修改日期

public record Metadata(String title, String author, String subject, List<String> keywords, String creator, String producer, Instant creationDate, Instant modDate) extends Record
PDF Document Metadata - Document information dictionary PDF 文档元数据 - 文档信息字典

Contains standard PDF metadata fields as defined in PDF specification.

包含 PDF 规范中定义的标准元数据字段。

Features | 主要功能:

  • Standard PDF metadata fields (title, author, subject, keywords) - 标准 PDF 元数据字段(标题、作者、主题、关键词)
  • Immutable record with builder support - 不可变记录,支持构建器
  • Copy-with methods for updating fields - 用于更新字段的 with 方法

Usage Examples | 使用示例:

Metadata meta = Metadata.builder()
    .title("My Document")
    .author("John Doe")
    .keywords("pdf", "document")
    .build();

Metadata updated = meta.withTitle("New Title");

Security | 安全性:

  • Thread-safe: Yes — immutable record - 线程安全: 是 — 不可变记录
  • Null-safe: Partial — fields may be null - 空值安全: 部分 — 字段可能为空
Since:
JDK 25, opencode-base-pdf V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Field Details

    • DEFAULT_PRODUCER

      public static final String DEFAULT_PRODUCER
      Default producer name | 默认生成器名称
      See Also:
  • Constructor Details

    • Metadata

      public Metadata(String title, String author, String subject, List<String> keywords, String creator, String producer, Instant creationDate, Instant modDate)
      Creates an instance of a Metadata record class.
      Parameters:
      title - the value for the title record component
      author - the value for the author record component
      subject - the value for the subject record component
      keywords - the value for the keywords record component
      creator - the value for the creator record component
      producer - the value for the producer record component
      creationDate - the value for the creationDate record component
      modDate - the value for the modDate record component
  • Method Details

    • empty

      public static Metadata empty()
      Creates empty metadata 创建空的元数据
      Returns:
      empty metadata | 空的元数据
    • ofTitle

      public static Metadata ofTitle(String title)
      Creates metadata with title only 仅创建带标题的元数据
      Parameters:
      title - document title | 文档标题
      Returns:
      metadata with title | 带标题的元数据
    • builder

      public static Metadata.Builder builder()
      Creates a builder for metadata 创建元数据构建器
      Returns:
      metadata builder | 元数据构建器
    • withTitle

      public Metadata withTitle(String newTitle)
      Creates a copy with updated title 创建更新标题后的副本
      Parameters:
      newTitle - new title | 新标题
      Returns:
      updated metadata | 更新后的元数据
    • withAuthor

      public Metadata withAuthor(String newAuthor)
      Creates a copy with updated author 创建更新作者后的副本
      Parameters:
      newAuthor - new author | 新作者
      Returns:
      updated metadata | 更新后的元数据
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • title

      public String title()
      Returns the value of the title record component.
      Returns:
      the value of the title record component
    • author

      public String author()
      Returns the value of the author record component.
      Returns:
      the value of the author record component
    • subject

      public String subject()
      Returns the value of the subject record component.
      Returns:
      the value of the subject record component
    • keywords

      public List<String> keywords()
      Returns the value of the keywords record component.
      Returns:
      the value of the keywords record component
    • creator

      public String creator()
      Returns the value of the creator record component.
      Returns:
      the value of the creator record component
    • producer

      public String producer()
      Returns the value of the producer record component.
      Returns:
      the value of the producer record component
    • creationDate

      public Instant creationDate()
      Returns the value of the creationDate record component.
      Returns:
      the value of the creationDate record component
    • modDate

      public Instant modDate()
      Returns the value of the modDate record component.
      Returns:
      the value of the modDate record component