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 Summary
ConstructorsConstructorDescriptionCollisionAnalysis(double probability, int recommendedSize, double recommendedProbability, String humanReadable, double entropyBits, long countToGen) Creates an instance of aCollisionAnalysisrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of thecountToGenrecord component.doubleReturns the value of theentropyBitsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thehumanReadablerecord component.booleanChecks if the collision risk is acceptable (probability < 1e-15).booleanChecks if the collision risk is low (probability < 1e-9).doubleReturns the value of theprobabilityrecord component.doubleReturns the value of therecommendedProbabilityrecord component.intReturns the value of therecommendedSizerecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
CollisionAnalysis
public CollisionAnalysis(double probability, int recommendedSize, double recommendedProbability, String humanReadable, double entropyBits, long countToGen) Creates an instance of aCollisionAnalysisrecord class.- Parameters:
probability- the value for theprobabilityrecord componentrecommendedSize- the value for therecommendedSizerecord componentrecommendedProbability- the value for therecommendedProbabilityrecord componenthumanReadable- the value for thehumanReadablerecord componententropyBits- the value for theentropyBitsrecord componentcountToGen- the value for thecountToGenrecord 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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
probability
public double probability()Returns the value of theprobabilityrecord component.- Returns:
- the value of the
probabilityrecord component
-
recommendedSize
public int recommendedSize()Returns the value of therecommendedSizerecord component.- Returns:
- the value of the
recommendedSizerecord component
-
recommendedProbability
public double recommendedProbability()Returns the value of therecommendedProbabilityrecord component.- Returns:
- the value of the
recommendedProbabilityrecord component
-
humanReadable
Returns the value of thehumanReadablerecord component.- Returns:
- the value of the
humanReadablerecord component
-
entropyBits
public double entropyBits()Returns the value of theentropyBitsrecord component.- Returns:
- the value of the
entropyBitsrecord component
-
countToGen
public long countToGen()Returns the value of thecountToGenrecord component.- Returns:
- the value of the
countToGenrecord component
-