mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
refactor: merge HashSet, ArrayList to MutableList
This commit is contained in:
@@ -44,7 +44,7 @@ abstract class ClassBaseFinder internal constructor(internal open val loaderSet:
|
||||
}
|
||||
|
||||
/** 当前找到的 [Class] 数组 */
|
||||
internal var classInstances = HashSet<Class<*>>()
|
||||
internal var classInstances = mutableListOf<Class<*>>()
|
||||
|
||||
/** 是否开启忽略错误警告功能 */
|
||||
internal var isIgnoreErrorLogs = false
|
||||
|
@@ -60,28 +60,28 @@ abstract class MemberBaseFinder internal constructor(private val tag: String, in
|
||||
internal var isIgnoreErrorLogs = false
|
||||
|
||||
/** 当前找到的 [Member] 数组 */
|
||||
internal var memberInstances = HashSet<Member>()
|
||||
internal var memberInstances = mutableListOf<Member>()
|
||||
|
||||
/**
|
||||
* 将 [HashSet]<[Member]> 转换为 [HashSet]<[Field]>
|
||||
* @return [HashSet]<[Field]>
|
||||
* 将 [MutableList]<[Member]> 转换为 [MutableList]<[Field]>
|
||||
* @return [MutableList]<[Field]>
|
||||
*/
|
||||
internal fun HashSet<Member>.fields() =
|
||||
hashSetOf<Field>().also { takeIf { e -> e.isNotEmpty() }?.forEach { e -> (e as? Field?)?.also { f -> it.add(f) } } }
|
||||
internal fun MutableList<Member>.fields() =
|
||||
mutableListOf<Field>().also { takeIf { e -> e.isNotEmpty() }?.forEach { e -> (e as? Field?)?.also { f -> it.add(f) } } }
|
||||
|
||||
/**
|
||||
* 将 [HashSet]<[Member]> 转换为 [HashSet]<[Method]>
|
||||
* @return [HashSet]<[Method]>
|
||||
* 将 [MutableList]<[Member]> 转换为 [MutableList]<[Method]>
|
||||
* @return [MutableList]<[Method]>
|
||||
*/
|
||||
internal fun HashSet<Member>.methods() =
|
||||
hashSetOf<Method>().also { takeIf { e -> e.isNotEmpty() }?.forEach { e -> (e as? Method?)?.also { m -> it.add(m) } } }
|
||||
internal fun MutableList<Member>.methods() =
|
||||
mutableListOf<Method>().also { takeIf { e -> e.isNotEmpty() }?.forEach { e -> (e as? Method?)?.also { m -> it.add(m) } } }
|
||||
|
||||
/**
|
||||
* 将 [HashSet]<[Member]> 转换为 [HashSet]<[Constructor]>
|
||||
* @return [HashSet]<[Constructor]>
|
||||
* 将 [MutableList]<[Member]> 转换为 [MutableList]<[Constructor]>
|
||||
* @return [MutableList]<[Constructor]>
|
||||
*/
|
||||
internal fun HashSet<Member>.constructors() =
|
||||
hashSetOf<Constructor<*>>().also { takeIf { e -> e.isNotEmpty() }?.forEach { e -> (e as? Constructor<*>?)?.also { c -> it.add(c) } } }
|
||||
internal fun MutableList<Member>.constructors() =
|
||||
mutableListOf<Constructor<*>>().also { takeIf { e -> e.isNotEmpty() }?.forEach { e -> (e as? Constructor<*>?)?.also { c -> it.add(c) } } }
|
||||
|
||||
/**
|
||||
* 将目标类型转换为可识别的兼容类型
|
||||
@@ -169,7 +169,7 @@ abstract class MemberBaseFinder internal constructor(private val tag: String, in
|
||||
* 绑定 [Member] 数组到当前 Hooker
|
||||
* @param members 当前 [Member] 数组
|
||||
*/
|
||||
internal fun bindMembers(members: HashSet<Member>) {
|
||||
internal fun bindMembers(members: MutableList<Member>) {
|
||||
instance?.members?.clear()
|
||||
members.forEach { instance?.members?.add(it) }
|
||||
}
|
||||
|
@@ -435,29 +435,29 @@ class DexClassFinder internal constructor(
|
||||
|
||||
/**
|
||||
* 得到 [Class] 或一组 [Class]
|
||||
* @return [HashSet]<[Class]>
|
||||
* @return [MutableList]<[Class]>
|
||||
* @throws NoClassDefFoundError 如果找不到 [Class]
|
||||
*/
|
||||
private val result get() = ReflectionTool.findClasses(loaderSet, rulesData)
|
||||
|
||||
/**
|
||||
* 从本地缓存读取 [Class] 数据
|
||||
* @return [HashSet]<[Class]>
|
||||
* @return [MutableList]<[Class]>
|
||||
*/
|
||||
private fun readFromCache(): HashSet<Class<*>> =
|
||||
private fun readFromCache(): MutableList<Class<*>> =
|
||||
if (async && name.isNotBlank()) currentContext?.let {
|
||||
hashSetOf<Class<*>>().also { classes ->
|
||||
mutableListOf<Class<*>>().also { classes ->
|
||||
it.currentSp().getStringSet(name, emptySet())?.takeIf { it.isNotEmpty() }
|
||||
?.forEach { className -> if (className.hasClass(loaderSet)) classes.add(className.toClass(loaderSet)) }
|
||||
}
|
||||
} ?: let { SystemClock.sleep(1); readFromCache() } else hashSetOf()
|
||||
} ?: let { SystemClock.sleep(1); readFromCache() } else mutableListOf()
|
||||
|
||||
/**
|
||||
* 将当前 [Class] 数组名称保存到本地缓存
|
||||
* @throws IllegalStateException 如果当前包名为 "android"
|
||||
*/
|
||||
private fun HashSet<Class<*>>.saveToCache() {
|
||||
if (name.isNotBlank() && isNotEmpty()) hashSetOf<String>().also { names ->
|
||||
private fun MutableList<Class<*>>.saveToCache() {
|
||||
if (name.isNotBlank() && isNotEmpty()) mutableSetOf<String>().also { names ->
|
||||
takeIf { it.isNotEmpty() }?.forEach { names.add(it.name) }
|
||||
currentContext?.also {
|
||||
if (it.packageName == "android") error("Cannot create classes cache for \"android\", please remove \"name\" param")
|
||||
@@ -470,7 +470,7 @@ class DexClassFinder internal constructor(
|
||||
* 设置实例
|
||||
* @param classes 当前找到的 [Class] 数组
|
||||
*/
|
||||
private fun setInstance(classes: HashSet<Class<*>>) {
|
||||
private fun setInstance(classes: MutableList<Class<*>>) {
|
||||
classInstances.clear()
|
||||
classes.takeIf { it.isNotEmpty() }?.forEach { classInstances.add(it) }
|
||||
}
|
||||
@@ -515,7 +515,7 @@ class DexClassFinder internal constructor(
|
||||
internal var waitResultCallback: ((Class<*>?) -> Unit)? = null
|
||||
|
||||
/** 异步方法体回调数组结果 */
|
||||
internal var waitAllResultCallback: ((HashSet<Class<*>>) -> Unit)? = null
|
||||
internal var waitAllResultCallback: ((MutableList<Class<*>>) -> Unit)? = null
|
||||
|
||||
/** 异常结果重新回调方法体 */
|
||||
internal var noClassDefFoundErrorCallback: (() -> Unit)? = null
|
||||
@@ -544,10 +544,10 @@ class DexClassFinder internal constructor(
|
||||
*
|
||||
* - 返回全部查找条件匹配的多个 [Class] 实例
|
||||
*
|
||||
* - 在查找条件找不到任何结果的时候将返回空的 [HashSet]
|
||||
* - 在查找条件找不到任何结果的时候将返回空的 [MutableList]
|
||||
*
|
||||
* - 若你设置了 [async] 请使用 [waitAll] 方法
|
||||
* @return [HashSet]<[Class]>
|
||||
* @return [MutableList]<[Class]>
|
||||
*/
|
||||
fun all() = classInstances
|
||||
|
||||
@@ -588,13 +588,13 @@ class DexClassFinder internal constructor(
|
||||
*
|
||||
* - 回调全部查找条件匹配的多个 [Class] 实例
|
||||
*
|
||||
* - 在查找条件找不到任何结果的时候将回调空的 [HashSet]
|
||||
* - 在查找条件找不到任何结果的时候将回调空的 [MutableList]
|
||||
*
|
||||
* - 你需要设置 [async] 后此方法才会被回调 - 否则请使用 [all] 方法
|
||||
* @param result 回调 - ([HashSet]<[Class]>)
|
||||
* @param result 回调 - ([MutableList]<[Class]>)
|
||||
* @return [Result] 可继续向下监听
|
||||
*/
|
||||
fun waitAll(result: (HashSet<Class<*>>) -> Unit): Result {
|
||||
fun waitAll(result: (MutableList<Class<*>>) -> Unit): Result {
|
||||
waitAllResultCallback = result
|
||||
return this
|
||||
}
|
||||
|
@@ -239,7 +239,7 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
||||
|
||||
/**
|
||||
* 得到 [Constructor] 或一组 [Constructor]
|
||||
* @return [HashSet]<[Constructor]>
|
||||
* @return [MutableList]<[Constructor]>
|
||||
* @throws NoSuchMethodError 如果找不到 [Constructor]
|
||||
*/
|
||||
private val result by lazy { ReflectionTool.findConstructors(usedClassSet, rulesData) }
|
||||
@@ -248,7 +248,7 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
||||
* 设置实例
|
||||
* @param constructors 当前找到的 [Constructor] 数组
|
||||
*/
|
||||
private fun setInstance(constructors: HashSet<Constructor<*>>) {
|
||||
private fun setInstance(constructors: MutableList<Constructor<*>>) {
|
||||
memberInstances.clear()
|
||||
constructors.takeIf { it.isNotEmpty() }?.onEach { memberInstances.add(it) }
|
||||
?.first()?.apply { if (hookerManager.isMemberBinded) hookerManager.bindMember(member = this) }
|
||||
@@ -293,7 +293,7 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
||||
inner class RemedyPlan internal constructor() {
|
||||
|
||||
/** 失败尝试次数数组 */
|
||||
private val remedyPlans = HashSet<Pair<ConstructorFinder, Result>>()
|
||||
private val remedyPlans = mutableSetOf<Pair<ConstructorFinder, Result>>()
|
||||
|
||||
/**
|
||||
* 创建需要重新查找的 [Constructor]
|
||||
@@ -344,13 +344,13 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
||||
inner class Result internal constructor() {
|
||||
|
||||
/** 找到结果时的回调 */
|
||||
internal var onFindCallback: (HashSet<Constructor<*>>.() -> Unit)? = null
|
||||
internal var onFindCallback: (MutableList<Constructor<*>>.() -> Unit)? = null
|
||||
|
||||
/**
|
||||
* 当找到结果时
|
||||
* @param initiate 回调
|
||||
*/
|
||||
fun onFind(initiate: HashSet<Constructor<*>>.() -> Unit) {
|
||||
fun onFind(initiate: MutableList<Constructor<*>>.() -> Unit) {
|
||||
onFindCallback = initiate
|
||||
}
|
||||
}
|
||||
@@ -378,7 +378,7 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
||||
* @return [Process] 可继续向下监听
|
||||
*/
|
||||
fun all(): Process {
|
||||
fun HashSet<Member>.bind() = takeIf { it.isNotEmpty() }?.apply { hookerManager.bindMembers(members = this) }.unit()
|
||||
fun MutableList<Member>.bind() = takeIf { it.isNotEmpty() }?.apply { hookerManager.bindMembers(members = this) }.unit()
|
||||
if (isUsingRemedyPlan)
|
||||
remedyPlansCallback = { memberInstances.bind() }
|
||||
else memberInstances.bind()
|
||||
@@ -452,9 +452,9 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
||||
* - 在 [memberInstances] 结果为空时使用此方法将无法获得对象
|
||||
*
|
||||
* - 若你设置了 [remedys] 请使用 [waitAll] 回调结果方法
|
||||
* @return [ArrayList]<[Instance]>
|
||||
* @return [MutableList]<[Instance]>
|
||||
*/
|
||||
fun all() = arrayListOf<Instance>().apply { giveAll().takeIf { it.isNotEmpty() }?.forEach { add(Instance(it)) } }
|
||||
fun all() = mutableListOf<Instance>().apply { giveAll().takeIf { it.isNotEmpty() }?.forEach { add(Instance(it)) } }
|
||||
|
||||
/**
|
||||
* 得到 [Constructor] 本身
|
||||
@@ -471,10 +471,10 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
||||
*
|
||||
* - 返回全部查找条件匹配的多个 [Constructor] 实例
|
||||
*
|
||||
* - 在查找条件找不到任何结果的时候将返回空的 [HashSet]
|
||||
* @return [HashSet]<[Constructor]>
|
||||
* - 在查找条件找不到任何结果的时候将返回空的 [MutableList]
|
||||
* @return [MutableList]<[Constructor]>
|
||||
*/
|
||||
fun giveAll() = memberInstances.takeIf { it.isNotEmpty() }?.constructors() ?: HashSet()
|
||||
fun giveAll() = memberInstances.takeIf { it.isNotEmpty() }?.constructors() ?: mutableListOf()
|
||||
|
||||
/**
|
||||
* 获得 [Constructor] 实例处理类
|
||||
@@ -499,9 +499,9 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
||||
* - 若你设置了 [remedys] 必须使用此方法才能获得结果
|
||||
*
|
||||
* - 若你没有设置 [remedys] 此方法将不会被回调
|
||||
* @param initiate 回调 [ArrayList]<[Instance]>
|
||||
* @param initiate 回调 [MutableList]<[Instance]>
|
||||
*/
|
||||
fun waitAll(initiate: ArrayList<Instance>.() -> Unit) {
|
||||
fun waitAll(initiate: MutableList<Instance>.() -> Unit) {
|
||||
if (memberInstances.isNotEmpty()) initiate(all())
|
||||
else remedyPlansCallback = { initiate(all()) }
|
||||
}
|
||||
|
@@ -195,7 +195,7 @@ class FieldFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
|
||||
/**
|
||||
* 得到 [Field] 或一组 [Field]
|
||||
* @return [HashSet]<[Field]>
|
||||
* @return [MutableList]<[Field]>
|
||||
* @throws NoSuchFieldError 如果找不到 [Field]
|
||||
*/
|
||||
private val result get() = ReflectionTool.findFields(usedClassSet, rulesData)
|
||||
@@ -204,7 +204,7 @@ class FieldFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
* 设置实例
|
||||
* @param fields 当前找到的 [Field] 数组
|
||||
*/
|
||||
private fun setInstance(fields: HashSet<Field>) {
|
||||
private fun setInstance(fields: MutableList<Field>) {
|
||||
memberInstances.clear()
|
||||
fields.takeIf { it.isNotEmpty() }?.forEach { memberInstances.add(it) }
|
||||
}
|
||||
@@ -241,7 +241,7 @@ class FieldFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
inner class RemedyPlan internal constructor() {
|
||||
|
||||
/** 失败尝试次数数组 */
|
||||
private val remedyPlans = HashSet<Pair<FieldFinder, Result>>()
|
||||
private val remedyPlans = mutableSetOf<Pair<FieldFinder, Result>>()
|
||||
|
||||
/**
|
||||
* 创建需要重新查找的 [Field]
|
||||
@@ -293,13 +293,13 @@ class FieldFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
inner class Result internal constructor() {
|
||||
|
||||
/** 找到结果时的回调 */
|
||||
internal var onFindCallback: (HashSet<Field>.() -> Unit)? = null
|
||||
internal var onFindCallback: (MutableList<Field>.() -> Unit)? = null
|
||||
|
||||
/**
|
||||
* 当找到结果时
|
||||
* @param initiate 回调
|
||||
*/
|
||||
fun onFind(initiate: HashSet<Field>.() -> Unit) {
|
||||
fun onFind(initiate: MutableList<Field>.() -> Unit) {
|
||||
onFindCallback = initiate
|
||||
}
|
||||
}
|
||||
@@ -349,10 +349,10 @@ class FieldFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
*
|
||||
* - 若你设置了 [remedys] 请使用 [waitAll] 回调结果方法
|
||||
* @param instance [Field] 所在的实例对象 - 如果是静态可不填 - 默认 null
|
||||
* @return [ArrayList]<[Instance]>
|
||||
* @return [MutableList]<[Instance]>
|
||||
*/
|
||||
fun all(instance: Any? = null) =
|
||||
arrayListOf<Instance>().apply { giveAll().takeIf { it.isNotEmpty() }?.forEach { add(Instance(instance, it)) } }
|
||||
mutableListOf<Instance>().apply { giveAll().takeIf { it.isNotEmpty() }?.forEach { add(Instance(instance, it)) } }
|
||||
|
||||
/**
|
||||
* 得到 [Field] 本身
|
||||
@@ -369,10 +369,10 @@ class FieldFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
*
|
||||
* - 返回全部查找条件匹配的多个 [Field] 实例
|
||||
*
|
||||
* - 在查找条件找不到任何结果的时候将返回空的 [HashSet]
|
||||
* @return [HashSet]<[Field]>
|
||||
* - 在查找条件找不到任何结果的时候将返回空的 [MutableList]
|
||||
* @return [MutableList]<[Field]>
|
||||
*/
|
||||
fun giveAll() = memberInstances.takeIf { it.isNotEmpty() }?.fields() ?: HashSet()
|
||||
fun giveAll() = memberInstances.takeIf { it.isNotEmpty() }?.fields() ?: mutableListOf()
|
||||
|
||||
/**
|
||||
* 获得 [Field] 实例处理类
|
||||
@@ -399,9 +399,9 @@ class FieldFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
*
|
||||
* - 若你没有设置 [remedys] 此方法将不会被回调
|
||||
* @param instance 所在实例
|
||||
* @param initiate 回调 [ArrayList]<[Instance]>
|
||||
* @param initiate 回调 [MutableList]<[Instance]>
|
||||
*/
|
||||
fun waitAll(instance: Any? = null, initiate: ArrayList<Instance>.() -> Unit) {
|
||||
fun waitAll(instance: Any? = null, initiate: MutableList<Instance>.() -> Unit) {
|
||||
if (memberInstances.isNotEmpty()) initiate(all(instance))
|
||||
else remedyPlansCallback = { initiate(all(instance)) }
|
||||
}
|
||||
|
@@ -332,7 +332,7 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
|
||||
/**
|
||||
* 得到 [Method] 或一组 [Method]
|
||||
* @return [HashSet]<[Method]>
|
||||
* @return [MutableList]<[Method]>
|
||||
* @throws NoSuchMethodError 如果找不到 [Method]
|
||||
*/
|
||||
private val result get() = ReflectionTool.findMethods(usedClassSet, rulesData)
|
||||
@@ -341,7 +341,7 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
* 设置实例
|
||||
* @param methods 当前找到的 [Method] 数组
|
||||
*/
|
||||
private fun setInstance(methods: HashSet<Method>) {
|
||||
private fun setInstance(methods: MutableList<Method>) {
|
||||
memberInstances.clear()
|
||||
methods.takeIf { it.isNotEmpty() }?.onEach { memberInstances.add(it) }
|
||||
?.first()?.apply { if (hookerManager.isMemberBinded) hookerManager.bindMember(member = this) }
|
||||
@@ -386,7 +386,7 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
inner class RemedyPlan internal constructor() {
|
||||
|
||||
/** 失败尝试次数数组 */
|
||||
private val remedyPlans = HashSet<Pair<MethodFinder, Result>>()
|
||||
private val remedyPlans = mutableSetOf<Pair<MethodFinder, Result>>()
|
||||
|
||||
/**
|
||||
* 创建需要重新查找的 [Method]
|
||||
@@ -438,13 +438,13 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
inner class Result internal constructor() {
|
||||
|
||||
/** 找到结果时的回调 */
|
||||
internal var onFindCallback: (HashSet<Method>.() -> Unit)? = null
|
||||
internal var onFindCallback: (MutableList<Method>.() -> Unit)? = null
|
||||
|
||||
/**
|
||||
* 当找到结果时
|
||||
* @param initiate 回调
|
||||
*/
|
||||
fun onFind(initiate: HashSet<Method>.() -> Unit) {
|
||||
fun onFind(initiate: MutableList<Method>.() -> Unit) {
|
||||
onFindCallback = initiate
|
||||
}
|
||||
}
|
||||
@@ -472,7 +472,7 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
* @return [Process] 可继续向下监听
|
||||
*/
|
||||
fun all(): Process {
|
||||
fun HashSet<Member>.bind() = takeIf { it.isNotEmpty() }?.apply { hookerManager.bindMembers(members = this) }.unit()
|
||||
fun MutableList<Member>.bind() = takeIf { it.isNotEmpty() }?.apply { hookerManager.bindMembers(members = this) }.unit()
|
||||
if (isUsingRemedyPlan)
|
||||
remedyPlansCallback = { memberInstances.bind() }
|
||||
else memberInstances.bind()
|
||||
@@ -548,10 +548,10 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
*
|
||||
* - 若你设置了 [remedys] 请使用 [waitAll] 回调结果方法
|
||||
* @param instance 所在实例
|
||||
* @return [ArrayList]<[Instance]>
|
||||
* @return [MutableList]<[Instance]>
|
||||
*/
|
||||
fun all(instance: Any? = null) =
|
||||
arrayListOf<Instance>().apply { giveAll().takeIf { it.isNotEmpty() }?.forEach { add(Instance(instance, it)) } }
|
||||
mutableListOf<Instance>().apply { giveAll().takeIf { it.isNotEmpty() }?.forEach { add(Instance(instance, it)) } }
|
||||
|
||||
/**
|
||||
* 得到 [Method] 本身
|
||||
@@ -568,10 +568,10 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
*
|
||||
* - 返回全部查找条件匹配的多个 [Method] 实例
|
||||
*
|
||||
* - 在查找条件找不到任何结果的时候将返回空的 [HashSet]
|
||||
* @return [HashSet]<[Method]>
|
||||
* - 在查找条件找不到任何结果的时候将返回空的 [MutableList]
|
||||
* @return [MutableList]<[Method]>
|
||||
*/
|
||||
fun giveAll() = memberInstances.takeIf { it.isNotEmpty() }?.methods() ?: HashSet()
|
||||
fun giveAll() = memberInstances.takeIf { it.isNotEmpty() }?.methods() ?: mutableListOf()
|
||||
|
||||
/**
|
||||
* 获得 [Method] 实例处理类
|
||||
@@ -598,9 +598,9 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
||||
*
|
||||
* - 若你没有设置 [remedys] 此方法将不会被回调
|
||||
* @param instance 所在实例
|
||||
* @param initiate 回调 [ArrayList]<[Instance]>
|
||||
* @param initiate 回调 [MutableList]<[Instance]>
|
||||
*/
|
||||
fun waitAll(instance: Any? = null, initiate: ArrayList<Instance>.() -> Unit) {
|
||||
fun waitAll(instance: Any? = null, initiate: MutableList<Instance>.() -> Unit) {
|
||||
if (memberInstances.isNotEmpty()) initiate(all(instance))
|
||||
else remedyPlansCallback = { initiate(all(instance)) }
|
||||
}
|
||||
|
@@ -151,12 +151,12 @@ internal object ReflectionTool {
|
||||
* 查找任意 [Class] 或一组 [Class]
|
||||
* @param loaderSet 类所在 [ClassLoader]
|
||||
* @param rulesData 规则查找数据
|
||||
* @return [HashSet]<[Class]>
|
||||
* @return [MutableList]<[Class]>
|
||||
* @throws IllegalStateException 如果 [loaderSet] 为 null 或未设置任何条件
|
||||
* @throws NoClassDefFoundError 如果找不到 [Class]
|
||||
*/
|
||||
internal fun findClasses(loaderSet: ClassLoader?, rulesData: ClassRulesData) = rulesData.createResult {
|
||||
hashSetOf<Class<*>>().also { classes ->
|
||||
mutableListOf<Class<*>>().also { classes ->
|
||||
/**
|
||||
* 开始查找作业
|
||||
* @param instance 当前 [Class] 实例
|
||||
@@ -294,14 +294,14 @@ internal object ReflectionTool {
|
||||
* 查找任意 [Field] 或一组 [Field]
|
||||
* @param classSet [Field] 所在类
|
||||
* @param rulesData 规则查找数据
|
||||
* @return [HashSet]<[Field]>
|
||||
* @return [MutableList]<[Field]>
|
||||
* @throws IllegalStateException 如果未设置任何条件或 [FieldRulesData.type] 目标类不存在
|
||||
* @throws NoSuchFieldError 如果找不到 [Field]
|
||||
*/
|
||||
internal fun findFields(classSet: Class<*>?, rulesData: FieldRulesData) = rulesData.createResult {
|
||||
if (type == UndefinedType) error("Field match type class is not found")
|
||||
if (classSet == null) return@createResult hashSetOf()
|
||||
hashSetOf<Field>().also { fields ->
|
||||
if (classSet == null) return@createResult mutableListOf()
|
||||
mutableListOf<Field>().also { fields ->
|
||||
classSet.existFields?.also { declares ->
|
||||
var iType = -1
|
||||
var iName = -1
|
||||
@@ -357,16 +357,16 @@ internal object ReflectionTool {
|
||||
* 查找任意 [Method] 或一组 [Method]
|
||||
* @param classSet [Method] 所在类
|
||||
* @param rulesData 规则查找数据
|
||||
* @return [HashSet]<[Method]>
|
||||
* @return [MutableList]<[Method]>
|
||||
* @throws IllegalStateException 如果未设置任何条件或 [MethodRulesData.paramTypes] 以及 [MethodRulesData.returnType] 目标类不存在
|
||||
* @throws NoSuchMethodError 如果找不到 [Method]
|
||||
*/
|
||||
internal fun findMethods(classSet: Class<*>?, rulesData: MethodRulesData) = rulesData.createResult {
|
||||
if (returnType == UndefinedType) error("Method match returnType class is not found")
|
||||
if (classSet == null) return@createResult hashSetOf()
|
||||
if (classSet == null) return@createResult mutableListOf()
|
||||
paramTypes?.takeIf { it.isNotEmpty() }
|
||||
?.forEachIndexed { p, it -> if (it == UndefinedType) error("Method match paramType[$p] class is not found") }
|
||||
hashSetOf<Method>().also { methods ->
|
||||
mutableListOf<Method>().also { methods ->
|
||||
classSet.existMethods?.also { declares ->
|
||||
var iReturnType = -1
|
||||
var iReturnTypeCds = -1
|
||||
@@ -468,15 +468,15 @@ internal object ReflectionTool {
|
||||
* 查找任意 [Constructor] 或一组 [Constructor]
|
||||
* @param classSet [Constructor] 所在类
|
||||
* @param rulesData 规则查找数据
|
||||
* @return [HashSet]<[Constructor]>
|
||||
* @return [MutableList]<[Constructor]>
|
||||
* @throws IllegalStateException 如果未设置任何条件或 [ConstructorRulesData.paramTypes] 目标类不存在
|
||||
* @throws NoSuchMethodError 如果找不到 [Constructor]
|
||||
*/
|
||||
internal fun findConstructors(classSet: Class<*>?, rulesData: ConstructorRulesData) = rulesData.createResult {
|
||||
if (classSet == null) return@createResult hashSetOf()
|
||||
if (classSet == null) return@createResult mutableListOf()
|
||||
paramTypes?.takeIf { it.isNotEmpty() }
|
||||
?.forEachIndexed { p, it -> if (it == UndefinedType) error("Constructor match paramType[$p] class is not found") }
|
||||
hashSetOf<Constructor<*>>().also { constructors ->
|
||||
mutableListOf<Constructor<*>>().also { constructors ->
|
||||
classSet.existConstructors?.also { declares ->
|
||||
var iParamTypes = -1
|
||||
var iParamTypesCds = -1
|
||||
|
Reference in New Issue
Block a user