Record Class NanoIdGenerator.CollisionAnalysis

java.lang.Object
java.lang.Record
cloud.opencode.base.id.nanoid.NanoIdGenerator.CollisionAnalysis
Record Components:
probability - the collision probability with default size | 默认长度的碰撞概率
recommendedSize - the recommended size for target probability | 达到目标概率的推荐长度
recommendedProbability - the probability with recommended size | 推荐长度的碰撞概率
humanReadable - human-readable probability description | 人类可读的概率描述
entropyBits - entropy bits with default size | 默认长度的熵位数
countToGen - the number of IDs analyzed | 分析的ID数量
Enclosing class:
NanoIdGenerator

public static record NanoIdGenerator.CollisionAnalysis(double probability, int recommendedSize, double recommendedProbability, String humanReadable, double entropyBits, long countToGen) extends Record
Collision analysis result 碰撞分析结果
Since:
JDK 25, opencode-base-id V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • CollisionAnalysis

      public CollisionAnalysis(double probability, int recommendedSize, double recommendedProbability, String humanReadable, double entropyBits, long countToGen)
      Creates an instance of a CollisionAnalysis record class.
      Parameters:
      probability - the value for the probability record component
      recommendedSize - the value for the recommendedSize record component
      recommendedProbability - the value for the recommendedProbability record component
      humanReadable - the value for the humanReadable record component
      entropyBits - the value for the entropyBits record component
      countToGen - the value for the countToGen record component
  • Method Details

    • isAcceptable

      public boolean isAcceptable()
      Checks if the collision risk is acceptable (probability < 1e-15). 检查碰撞风险是否可接受(概率 < 1e-15)。
      Returns:
      true if acceptable | 如果可接受返回true
    • isLowRisk

      public boolean isLowRisk()
      Checks if the collision risk is low (probability < 1e-9). 检查碰撞风险是否低(概率 < 1e-9)。
      Returns:
      true if low risk | 如果低风险返回true
    • 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.
    • probability

      public double probability()
      Returns the value of the probability record component.
      Returns:
      the value of the probability record component
    • recommendedSize

      public int recommendedSize()
      Returns the value of the recommendedSize record component.
      Returns:
      the value of the recommendedSize record component
    • recommendedProbability

      public double recommendedProbability()
      Returns the value of the recommendedProbability record component.
      Returns:
      the value of the recommendedProbability record component
    • humanReadable

      public String humanReadable()
      Returns the value of the humanReadable record component.
      Returns:
      the value of the humanReadable record component
    • entropyBits

      public double entropyBits()
      Returns the value of the entropyBits record component.
      Returns:
      the value of the entropyBits record component
    • countToGen

      public long countToGen()
      Returns the value of the countToGen record component.
      Returns:
      the value of the countToGen record component