Enum Class CompressionAlgorithm
java.lang.Object
java.lang.Enum<CompressionAlgorithm>
cloud.opencode.base.serialization.compress.CompressionAlgorithm
- All Implemented Interfaces:
Serializable, Comparable<CompressionAlgorithm>, Constable
CompressionAlgorithm - Compression Algorithm Enumeration
压缩算法枚举
Defines the available compression algorithms for serialized data.
定义序列化数据可用的压缩算法。
Available Algorithms | 可用算法:
- NONE - No compression - 无压缩
- GZIP - GZIP compression (JDK built-in) - GZIP 压缩(JDK 内置)
- LZ4 - LZ4 fast compression - LZ4 快速压缩
- SNAPPY - Snappy compression - Snappy 压缩
- ZSTD - Zstandard high-ratio compression - Zstandard 高压缩比压缩
Selection Guide | 选择指南:
- GZIP - Best compression ratio, moderate speed - 最佳压缩比,中等速度
- LZ4 - Fastest speed, moderate compression - 最快速度,中等压缩比
- SNAPPY - Good balance for real-time - 实时场景的良好平衡
- ZSTD - Best overall (ratio + speed) - 最佳综合表现
Features | 主要功能:
- Supported compression algorithm enumeration - 支持的压缩算法枚举
- GZIP, LZ4, Snappy, Deflate, ZSTD support - 支持GZIP、LZ4、Snappy、Deflate、ZSTD
Usage Examples | 使用示例:
// Select compression for serialization
// 为序列化选择压缩算法
CompressedSerializer serializer = new CompressedSerializer(
delegate, CompressionAlgorithm.LZ4
);
Security | 安全性:
- Thread-safe: Yes (immutable enum) - 线程安全: 是(不可变枚举)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-serialization V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionGZIP compression (JDK built-in) GZIP 压缩(JDK 内置)LZ4 fast compression (requires lz4-java) LZ4 快速压缩(需要 lz4-java)No compression 无压缩Snappy compression (requires snappy-java) Snappy 压缩(需要 snappy-java)Zstandard high-ratio compression (requires zstd-jni) Zstandard 高压缩比压缩(需要 zstd-jni) -
Method Summary
Modifier and TypeMethodDescriptionstatic CompressionAlgorithmfromId(byte id) Returns the algorithm from its identifier.static CompressionAlgorithmReturns the algorithm from its name.bytegetId()Returns the algorithm identifier.getName()Returns the algorithm name.booleanChecks if this algorithm is available on the current classpath.booleanReturns whether this algorithm is built-in to JDK.static CompressionAlgorithmReturns the enum constant of this class with the specified name.static CompressionAlgorithm[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NONE
No compression 无压缩 -
GZIP
GZIP compression (JDK built-in) GZIP 压缩(JDK 内置) -
LZ4
LZ4 fast compression (requires lz4-java) LZ4 快速压缩(需要 lz4-java) -
SNAPPY
Snappy compression (requires snappy-java) Snappy 压缩(需要 snappy-java) -
ZSTD
Zstandard high-ratio compression (requires zstd-jni) Zstandard 高压缩比压缩(需要 zstd-jni)
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getName
-
getId
public byte getId()Returns the algorithm identifier. 返回算法标识符。- Returns:
- the identifier - 标识符
-
isBuiltIn
public boolean isBuiltIn()Returns whether this algorithm is built-in to JDK. 返回此算法是否为 JDK 内置。- Returns:
- true if built-in - 如果是内置的则返回 true
-
isAvailable
public boolean isAvailable()Checks if this algorithm is available on the current classpath. 检查此算法在当前类路径上是否可用。- Returns:
- true if available - 如果可用则返回 true
-
fromId
Returns the algorithm from its identifier. 从标识符返回算法。- Parameters:
id- the identifier - 标识符- Returns:
- the algorithm, or NONE if not found - 算法,如果未找到则返回 NONE
-
fromName
Returns the algorithm from its name. 从名称返回算法。- Parameters:
name- the name (case-insensitive) - 名称(不区分大小写)- Returns:
- the algorithm, or NONE if not found - 算法,如果未找到则返回 NONE
-