dsl/kotless/cloud/kotless-lang-aws/src/main/kotlin/io/kotless/dsl/app/events/EventsReflectionScanner.kt [1:36]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - package io.kotless.dsl.app.events import io.kotless.InternalAPI import io.kotless.ScheduledEventType import io.kotless.dsl.lang.event.Scheduled import io.kotless.dsl.reflection.ReflectionScanner import java.lang.reflect.Method import kotlin.math.absoluteValue import kotlin.reflect.KFunction import kotlin.reflect.full.findAnnotation import kotlin.reflect.jvm.kotlinFunction @InternalAPI object EventsReflectionScanner { data class Data(val ids: Set, val method: Method, val annotation: Scheduled) fun getEvents(): Set { val events = HashSet() for (method in ReflectionScanner.methodsWithAnnotation()) { events.add(Data(method.toIDs(), method, method.toAnnotation()!!)) } return events } private fun Method.toAnnotation() = (kotlinFunction as KFunction<*>).findAnnotation() private fun Method.toIDs(): Set { val annotation = toAnnotation()!! return annotation.id.takeIf { it.isNotBlank() }?.let { setOf(it) } ?: run { val klass = declaringClass.kotlin.qualifiedName!! setOf("$klass.$name", "${klass.substringBeforeLast(".")}.$name") .map { "${ScheduledEventType.General.prefix}-${it.hashCode().absoluteValue}" } .toSet() - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - dsl/kotless/cloud/kotless-lang-azure/src/main/kotlin/io/kotless/dsl/events/EventsReflectionScanner.kt [1:36]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - package io.kotless.dsl.app.events import io.kotless.InternalAPI import io.kotless.ScheduledEventType import io.kotless.dsl.lang.event.Scheduled import io.kotless.dsl.reflection.ReflectionScanner import java.lang.reflect.Method import kotlin.math.absoluteValue import kotlin.reflect.KFunction import kotlin.reflect.full.findAnnotation import kotlin.reflect.jvm.kotlinFunction @InternalAPI object EventsReflectionScanner { data class Data(val ids: Set, val method: Method, val annotation: Scheduled) fun getEvents(): Set { val events = HashSet() for (method in ReflectionScanner.methodsWithAnnotation()) { events.add(Data(method.toIDs(), method, method.toAnnotation()!!)) } return events } private fun Method.toAnnotation() = (kotlinFunction as KFunction<*>).findAnnotation() private fun Method.toIDs(): Set { val annotation = toAnnotation()!! return annotation.id.takeIf { it.isNotBlank() }?.let { setOf(it) } ?: run { val klass = declaringClass.kotlin.qualifiedName!! setOf("$klass.$name", "${klass.substringBeforeLast(".")}.$name") .map { "${ScheduledEventType.General.prefix}-${it.hashCode().absoluteValue}" } .toSet() - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -