getArg

inline fun <T> AnnotationInfo.getArg(paramName: String): T(source)

Returns the annotation argument value for the parameter named paramName, cast to T.

Example

@Before(target = [RateLimit::class])
fun doBefore(jp: JoinPoint) {
val info = jp.findAnnotation<RateLimit>()!!
val maxCalls = info.getArg<Int>("maxCalls")
}

Throws

if no parameter with paramName exists in the annotation.

if the argument value cannot be cast to T.


inline fun <T> JoinPoint.getArg(name: String): T(source)

Returns the argument value for the parameter named name, cast to T.

Example

@Around(target = [Transactional::class])
fun doAround(pjp: ProceedingJoinPoint): Any? {
val userId = pjp.getArg<String>("userId")
return pjp.proceed()
}

Throws

if no parameter with name exists on the intercepted function.

if the argument value cannot be cast to T.