mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-07 11:10:04 +08:00
Merge pull request #38 from yangyiyu08/master
Fix get interfaces of class in ReflectionFactory
This commit is contained in:
@@ -146,7 +146,12 @@ 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
|
/**
|
||||||
|
* 获取当前 [Class] 实现的所有接口类
|
||||||
|
* @return [Set]<[Class]>
|
||||||
|
*/
|
||||||
|
fun Class<*>.findAllInterfaces(): Set<Class<*>> = mutableSetOf(*interfaces).apply { superclass?.also { addAll(it.findAllInterfaces()) } }
|
||||||
|
return findAllInterfaces().takeIf { it.isNotEmpty() }?.any { it.name == other.name } ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -406,4 +411,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