se.ansman.kotshi.kapt.AnnotationMirrors.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compiler Show documentation
Show all versions of compiler Show documentation
An annotations processor that generates Moshi adapters from Kotlin data classes
The newest version!
package se.ansman.kotshi.kapt
import javax.lang.model.element.AnnotationMirror
inline fun AnnotationMirror.getValue(name: String): R =
getValueOrNull(name) ?: throw IllegalArgumentException("Annotation $this has no value $name")
inline fun AnnotationMirror.getValueOrNull(name: String): R? =
elementValues.entries
.find { it.key.simpleName.contentEquals(name) }
?.value
?.value as R?