Record Class SerializerInfo

java.lang.Object
java.lang.Record
cloud.opencode.base.serialization.SerializerInfo
Record Components:
format - the serialization format name (e.g., "json", "xml", "kryo") | 序列化格式名称
mimeType - the MIME type (e.g., "application/json") | MIME 类型
textBased - whether the serializer produces text output | 是否产生文本输出
supportsStreaming - whether the serializer natively supports streaming | 是否原生支持流式处理
supportsCompression - whether the serializer supports built-in compression | 是否支持内置压缩
description - a human-readable description | 可读描述

public record SerializerInfo(String format, String mimeType, boolean textBased, boolean supportsStreaming, boolean supportsCompression, String description) extends Record
SerializerInfo - Serializer Capability and Metadata Descriptor 序列化器能力与元数据描述符

An immutable record that describes a serializer's capabilities, including its format, MIME type, whether it is text-based, and optional features like streaming and compression support.

一个不可变记录,描述序列化器的能力,包括格式、MIME 类型、是否基于文本, 以及流式处理和压缩支持等可选功能。

Features | 主要功能:

  • Format identification - 格式标识
  • MIME type metadata - MIME 类型元数据
  • Capability flags (text, streaming, compression) - 能力标志(文本、流式、压缩)
  • Human-readable description - 可读描述

Usage Examples | 使用示例:

// Get info from a serializer
SerializerInfo info = serializer.info();
System.out.println(info.format());       // "json"
System.out.println(info.mimeType());     // "application/json"
System.out.println(info.textBased());    // true

// Create directly
SerializerInfo info = new SerializerInfo("json", "application/json", true, true, false, "JSON serializer");

// List all serializer infos
List<SerializerInfo> all = OpenSerializer.listSerializers();

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
Since:
JDK 25, opencode-base-serialization V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • SerializerInfo

      public SerializerInfo(String format, String mimeType, boolean textBased, boolean supportsStreaming, boolean supportsCompression, String description)
      Canonical constructor with validation. 带验证的规范构造函数。
      Parameters:
      format - the serialization format name | 序列化格式名称
      mimeType - the MIME type | MIME 类型
      textBased - whether text-based | 是否基于文本
      supportsStreaming - whether streaming is supported | 是否支持流式
      supportsCompression - whether compression is supported | 是否支持压缩
      description - the description | 描述
  • Method Details

    • toString

      public 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • format

      public String format()
      Returns the value of the format record component.
      Returns:
      the value of the format record component
    • mimeType

      public String mimeType()
      Returns the value of the mimeType record component.
      Returns:
      the value of the mimeType record component
    • textBased

      public boolean textBased()
      Returns the value of the textBased record component.
      Returns:
      the value of the textBased record component
    • supportsStreaming

      public boolean supportsStreaming()
      Returns the value of the supportsStreaming record component.
      Returns:
      the value of the supportsStreaming record component
    • supportsCompression

      public boolean supportsCompression()
      Returns the value of the supportsCompression record component.
      Returns:
      the value of the supportsCompression record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component