All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.ks.kes.lib.SerializationId.kt Maven / Gradle / Ivy

package no.ks.kes.lib

import kotlin.reflect.KClass
import kotlin.reflect.full.findAnnotation

@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
annotation class SerializationId(val value: String)

fun  getSerializationIdAnnotationValue(clazz: KClass): String =
        (clazz.findAnnotation()
                ?.value
                ?: error("The class ${clazz.simpleName} is not annotated with @SerializationId")
                ).also { check(it.isNotBlank()) { "The class ${clazz.simpleName} is annotated with @SerializationId, but the value is empty" } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy