com.flyjingfish.android_aop_annotation.impl.JoinPoint.kt Maven / Gradle / Ivy
package com.flyjingfish.android_aop_annotation.impl
import com.flyjingfish.android_aop_annotation.AopMethod
import com.flyjingfish.android_aop_annotation.ProceedJoinPoint
import com.flyjingfish.android_aop_annotation.impl.ProceedJoinPointImpl.OnInvokeListener
import com.flyjingfish.android_aop_annotation.utils.InvokeMethod
import java.lang.reflect.Method
internal object JoinPoint {
fun getJoinPoint(
targetClass: Class<*>,
args: Array?,
target: Any?,
isSuspend: Boolean,
targetMethod: Method,
invokeMethod: InvokeMethod,
aopMethod: AopMethod
): ProceedJoinPointImpl {
return ProceedJoinPointImpl(
targetClass,
args,
target,
isSuspend,
targetMethod,
invokeMethod,
aopMethod
)
}
fun getJoinPointSuspend(
targetClass: Class<*>,
args: Array?,
target: Any?,
isSuspend: Boolean,
targetMethod: Method,
invokeMethod: InvokeMethod,
aopMethod: AopMethod
): ProceedJoinPointImpl {
return ProceedJoinPointSuspendImpl(
targetClass,
args,
target,
isSuspend,
targetMethod,
invokeMethod,
aopMethod
)
}
fun setOnInvokeListener(proceedJoinPoint: ProceedJoinPoint, function: () -> Any?) {
if (proceedJoinPoint is ProceedJoinPointImpl){
proceedJoinPoint.setOnInvokeListener(OnInvokeListener { function.invoke() })
}
}
fun setHasNext(proceedJoinPoint: ProceedJoinPoint,hasNext: Boolean) {
if (proceedJoinPoint is ProceedJoinPointImpl){
proceedJoinPoint.setHasNext(hasNext)
}
}
}