mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 18:55:35 +08:00
fix get interfaces of class
fix get interfaces of class
This commit is contained in:
@@ -146,7 +146,20 @@ infix fun Class<*>?.notExtends(other: Class<*>?) = extends(other).not()
|
|||||||
*/
|
*/
|
||||||
infix fun Class<*>?.implements(other: Class<*>?): Boolean {
|
infix fun Class<*>?.implements(other: Class<*>?): Boolean {
|
||||||
if (this == null || other == null) return false
|
if (this == null || other == null) return false
|
||||||
return interfaces.takeIf { it.isNotEmpty() }?.any { it.name == other.name } ?: false
|
return getAllInterfaces().takeIf { it.isNotEmpty() }?.any { it.name == other.name } ?: false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前 [Class] 实现的所有接口类
|
||||||
|
*
|
||||||
|
* @return [Set]<[Class]<*>>
|
||||||
|
*/
|
||||||
|
private fun Class<*>.getAllInterfaces(): Set<Class<*>> {
|
||||||
|
val interfaces = mutableSetOf(*interfaces)
|
||||||
|
superclass?.let { superClass ->
|
||||||
|
interfaces.addAll(superClass.getAllInterfaces())
|
||||||
|
}
|
||||||
|
return interfaces
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -406,4 +419,4 @@ inline fun Class<*>.allConstructors(isAccessible: Boolean = true, result: (index
|
|||||||
* @param result 回调 - ([Int] 下标,[Field] 实例)
|
* @param result 回调 - ([Int] 下标,[Field] 实例)
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.allFields(isAccessible: Boolean = true, result: (index: Int, field: Field) -> Unit) =
|
inline fun Class<*>.allFields(isAccessible: Boolean = true, result: (index: Int, field: Field) -> Unit) =
|
||||||
declaredFields.forEachIndexed { p, it -> result(p, it.also { e -> e.isAccessible = isAccessible }) }
|
declaredFields.forEachIndexed { p, it -> result(p, it.also { e -> e.isAccessible = isAccessible }) }
|
||||||
|
Reference in New Issue
Block a user