mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 17:55:24 +08:00
Added length function in NameConditions
This commit is contained in:
@@ -88,6 +88,24 @@ fun matches(regex: Regex)
|
|||||||
|
|
||||||
> 正则字符匹配。
|
> 正则字符匹配。
|
||||||
|
|
||||||
|
### length *- method*
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
fun length(num: Int)
|
||||||
|
```
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
fun length(numRange: IntRange)
|
||||||
|
```
|
||||||
|
|
||||||
|
**变更记录**
|
||||||
|
|
||||||
|
`v1.0.93` `新增`
|
||||||
|
|
||||||
|
**功能描述**
|
||||||
|
|
||||||
|
> 字符长度与范围匹配。
|
||||||
|
|
||||||
### thisSynthetic0 *- method*
|
### thisSynthetic0 *- method*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
|
@@ -55,6 +55,12 @@ class NameConditions @PublishedApi internal constructor() {
|
|||||||
/** 正则字符匹配条件 */
|
/** 正则字符匹配条件 */
|
||||||
private var cdsMatches: Regex? = null
|
private var cdsMatches: Regex? = null
|
||||||
|
|
||||||
|
/** 字符长度匹配条件 */
|
||||||
|
private var cdsLength = -1
|
||||||
|
|
||||||
|
/** 字符长度范围匹配条件 */
|
||||||
|
private var cdsLengthRange = IntRange.EMPTY
|
||||||
|
|
||||||
/** 标识为匿名类的主类调用对象条件 */
|
/** 标识为匿名类的主类调用对象条件 */
|
||||||
private var isThisSynthetic0 = false
|
private var isThisSynthetic0 = false
|
||||||
|
|
||||||
@@ -143,6 +149,22 @@ class NameConditions @PublishedApi internal constructor() {
|
|||||||
cdsMatches = regex
|
cdsMatches = regex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符长度匹配
|
||||||
|
* @param num 预期的长度
|
||||||
|
*/
|
||||||
|
fun length(num: Int) {
|
||||||
|
cdsLength = num
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符长度范围匹配
|
||||||
|
* @param numRange 预期的长度范围
|
||||||
|
*/
|
||||||
|
fun length(numRange: IntRange) {
|
||||||
|
cdsLengthRange = numRange
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标识为匿名类的主类调用对象
|
* 标识为匿名类的主类调用对象
|
||||||
*
|
*
|
||||||
@@ -247,6 +269,8 @@ class NameConditions @PublishedApi internal constructor() {
|
|||||||
if (cdsEndsWith != null) cdsEndsWith?.apply { conditions = conditions && it.endsWith(first, second) }
|
if (cdsEndsWith != null) cdsEndsWith?.apply { conditions = conditions && it.endsWith(first, second) }
|
||||||
if (cdsContains != null) cdsContains?.apply { conditions = conditions && it.contains(first, second) }
|
if (cdsContains != null) cdsContains?.apply { conditions = conditions && it.contains(first, second) }
|
||||||
if (cdsMatches != null) cdsMatches?.apply { conditions = conditions && it.matches(regex = this) }
|
if (cdsMatches != null) cdsMatches?.apply { conditions = conditions && it.matches(regex = this) }
|
||||||
|
if (cdsLength >= 0) conditions = conditions && it.length == cdsLength
|
||||||
|
if (cdsLengthRange != IntRange.EMPTY) conditions = conditions && it.length in cdsLengthRange
|
||||||
}
|
}
|
||||||
return conditions
|
return conditions
|
||||||
}
|
}
|
||||||
@@ -265,6 +289,8 @@ class NameConditions @PublishedApi internal constructor() {
|
|||||||
if (cdsEndsWith != null) cdsEndsWith?.apply { conditions += "<EndsWith:[suffix: $first, isIgnoreCase: $second]> " }
|
if (cdsEndsWith != null) cdsEndsWith?.apply { conditions += "<EndsWith:[suffix: $first, isIgnoreCase: $second]> " }
|
||||||
if (cdsContains != null) cdsContains?.apply { conditions += "<Contains:[other: $first, isIgnoreCase: $second]> " }
|
if (cdsContains != null) cdsContains?.apply { conditions += "<Contains:[other: $first, isIgnoreCase: $second]> " }
|
||||||
if (cdsMatches != null) cdsMatches?.apply { conditions += "<Matches:[regex: $this]> " }
|
if (cdsMatches != null) cdsMatches?.apply { conditions += "<Matches:[regex: $this]> " }
|
||||||
|
if (cdsLength >= 0) conditions += "<Length:[num: $cdsLength]> "
|
||||||
|
if (cdsLengthRange != IntRange.EMPTY) conditions += "<LengthRange:[numRange: $cdsLengthRange]> "
|
||||||
return "[${conditions.trim()}]"
|
return "[${conditions.trim()}]"
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user