Fix get interfaces of class by (@yangyiyu08) in ReflectionFactory

This commit is contained in:
2023-05-05 23:50:25 +08:00
parent 2b90d7ebb6
commit 6067ce9123

View File

@@ -124,7 +124,12 @@ 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
/**
* 获取当前 [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
}
/**