Enum Class CompressionAlgorithm

java.lang.Object
java.lang.Enum<CompressionAlgorithm>
cloud.opencode.base.cache.compression.CompressionAlgorithm
All Implemented Interfaces:
Serializable, Comparable<CompressionAlgorithm>, Constable

public enum CompressionAlgorithm extends Enum<CompressionAlgorithm>
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:
  • Enum Constant Details

    • NONE

      public static final CompressionAlgorithm NONE
      No compression - 无压缩
    • GZIP

      public static final CompressionAlgorithm GZIP
      GZIP compression - Good compression ratio, moderate speed GZIP 压缩 - 压缩率好,速度适中
    • LZ4

      public static final CompressionAlgorithm LZ4
      LZ4 compression - Fast compression, moderate ratio LZ4 压缩 - 压缩速度快,压缩率适中
    • ZSTD

      public static final CompressionAlgorithm ZSTD
      ZSTD compression - Best balance of speed and ratio ZSTD 压缩 - 速度和压缩率的最佳平衡
    • SNAPPY

      public static final CompressionAlgorithm SNAPPY
      Snappy compression - Very fast, lower ratio Snappy 压缩 - 非常快,压缩率较低
  • Method Details

    • values

      public static CompressionAlgorithm[] 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

      public static CompressionAlgorithm valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • id

      public int id()
      Get algorithm ID 获取算法 ID
      Returns:
      algorithm ID | 算法 ID
    • algorithmName

      public String algorithmName()
      Get algorithm name 获取算法名称
      Returns:
      algorithm name | 算法名称
    • defaultLevel

      public int defaultLevel()
      Get default compression level 获取默认压缩级别
      Returns:
      default level | 默认级别
    • fromId

      public static CompressionAlgorithm fromId(int id)
      Get algorithm by ID 根据 ID 获取算法
      Parameters:
      id - algorithm ID | 算法 ID
      Returns:
      algorithm | 算法
    • fromName

      public static CompressionAlgorithm fromName(String name)
      Get algorithm by name 根据名称获取算法
      Parameters:
      name - algorithm name | 算法名称
      Returns:
      algorithm | 算法