Enum Class CompressionAlgorithm
- All Implemented Interfaces:
Serializable, Comparable<CompressionAlgorithm>, Constable
Compression Algorithm Enumeration
压缩算法枚举
Defines available compression algorithms for cache value compression.
定义缓存值压缩的可用压缩算法。
Features | 主要功能:
- GZIP - Good compression ratio - GZIP - 良好压缩率
- LZ4 - Fast compression - LZ4 - 快速压缩
- ZSTD - Best balance of speed and ratio - ZSTD - 速度和压缩率的最佳平衡
- Snappy - Very fast, lower ratio - Snappy - 非常快,较低压缩率
Usage Examples | 使用示例:
CompressionAlgorithm algo = CompressionAlgorithm.GZIP;
String name = algo.algorithmName();
Security | 安全性:
- Thread-safe: Yes (immutable enum) - 线程安全: 是(不可变枚举)
- Null-safe: Yes - 空值安全: 是
Performance | 性能特性:
- Time complexity: O(k) for fromId/fromName where k is the number of enum constants (5) - 时间复杂度: fromId/fromName 为 O(k),k为枚举常量数量(5)
- Space complexity: O(1) - 空间复杂度: O(1)
- Since:
- JDK 25, opencode-base-cache V2.0.5
- 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 - Good compression ratio, moderate speed GZIP 压缩 - 压缩率好,速度适中LZ4 compression - Fast compression, moderate ratio LZ4 压缩 - 压缩速度快,压缩率适中No compression - 无压缩Snappy compression - Very fast, lower ratio Snappy 压缩 - 非常快,压缩率较低ZSTD compression - Best balance of speed and ratio ZSTD 压缩 - 速度和压缩率的最佳平衡 -
Method Summary
Modifier and TypeMethodDescriptionGet algorithm name 获取算法名称intGet default compression level 获取默认压缩级别static CompressionAlgorithmfromId(int id) Get algorithm by ID 根据 ID 获取算法static CompressionAlgorithmGet algorithm by name 根据名称获取算法intid()Get algorithm ID 获取算法 IDstatic 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 - Good compression ratio, moderate speed GZIP 压缩 - 压缩率好,速度适中 -
LZ4
LZ4 compression - Fast compression, moderate ratio LZ4 压缩 - 压缩速度快,压缩率适中 -
ZSTD
ZSTD compression - Best balance of speed and ratio ZSTD 压缩 - 速度和压缩率的最佳平衡 -
SNAPPY
Snappy compression - Very fast, lower ratio Snappy 压缩 - 非常快,压缩率较低
-
-
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
-
id
public int id()Get algorithm ID 获取算法 ID- Returns:
- algorithm ID | 算法 ID
-
algorithmName
-
defaultLevel
public int defaultLevel()Get default compression level 获取默认压缩级别- Returns:
- default level | 默认级别
-
fromId
Get algorithm by ID 根据 ID 获取算法- Parameters:
id- algorithm ID | 算法 ID- Returns:
- algorithm | 算法
-
fromName
Get algorithm by name 根据名称获取算法- Parameters:
name- algorithm name | 算法名称- Returns:
- algorithm | 算法
-