mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +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 {
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user