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 内置)
- DEFLATE - Deflate compression (JDK built-in) - Deflate 压缩(JDK 内置)
Selection Guide | 选择指南:
- GZIP - Best compression ratio, moderate speed - 最佳压缩比,中等速度
- DEFLATE - Slightly faster than GZIP, slightly less overhead - 比 GZIP 略快,开销略小
Features | 主要功能:
- Supported compression algorithm enumeration - 支持的压缩算法枚举
- GZIP, Deflate support (JDK built-in) - 支持 GZIP、Deflate(JDK 内置)
Usage Examples | 使用示例:
// Select compression for serialization
// 为序列化选择压缩算法
CompressedSerializer serializer = new CompressedSerializer(
delegate, CompressionAlgorithm.GZIP
);
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 Constants -
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 内置) -
DEFLATE
Deflate compression (JDK built-in) Deflate 压缩(JDK 内置)
-
-
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
-