Record Class FuzzyMatch<T>
java.lang.Object
java.lang.Record
cloud.opencode.base.string.match.FuzzyMatch<T>
- Type Parameters:
T- the type of the matched item | 匹配项目的类型- Record Components:
item- the matched item | 匹配的项目key- the string key used for matching | 用于匹配的字符串键score- the similarity score (0.0 - 1.0) | 相似度分数(0.0 - 1.0)Security | 安全性:
- Thread-safe: Yes (record is immutable) - 线程安全: 是(记录不可变)
Fuzzy Match Result - Represents a fuzzy matching result
模糊匹配结果 - 表示一个模糊匹配的结果
Contains the matched item, its string key, and the similarity score.
包含匹配的项目、其字符串键和相似度分数。
Features | 主要功能:
- Score as percentage display - 分数百分比显示
- Match strength classification (exact, strong, weak) - 匹配强度分类
Usage Examples | 使用示例:
FuzzyMatch<String> match = ...;
String item = match.item(); // The matched item
String key = match.key(); // The string used for matching
double score = match.score(); // Similarity score (0.0 - 1.0)
- Since:
- JDK 25, opencode-base-string V1.2.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFuzzyMatch(T item, String key, double score) Creates an instance of aFuzzyMatchrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanChecks if this is an exact match.booleanChecks if this is a strong match (score >= 0.8).booleanChecks if this is a weak match (score < 0.6).item()Returns the value of theitemrecord component.key()Returns the value of thekeyrecord component.doublescore()Returns the value of thescorerecord component.Returns a formatted score as percentage.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
FuzzyMatch
-
-
Method Details
-
scoreAsPercent
Returns a formatted score as percentage. 返回格式化为百分比的分数。- Returns:
- score as percentage string | 百分比字符串形式的分数
-
isExactMatch
public boolean isExactMatch()Checks if this is an exact match. 检查是否为精确匹配。- Returns:
- true if score is 1.0 | 如果分数为1.0则返回true
-
isStrongMatch
public boolean isStrongMatch()Checks if this is a strong match (score >= 0.8). 检查是否为强匹配(分数 >= 0.8)。- Returns:
- true if score >= 0.8 | 如果分数 >= 0.8则返回true
-
isWeakMatch
public boolean isWeakMatch()Checks if this is a weak match (score < 0.6). 检查是否为弱匹配(分数 < 0.6)。- Returns:
- true if
score < 0.6| 如果分数小于 0.6 则返回 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. -
item
-
key
-
score
-