I'm using Auto Service to process some annotations but I'm unable to identify if a Kotlin class has the "internal" visibility modifier from the Annotation Processor API.
I'm using KAPT and Kotlin in the processor. Dependencies:
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: "1.3.0-rc-190"
implementation files("${System.properties['java.home']}/../lib/tools.jar")
implementation 'com.squareup:kotlinpoet:1.0.0-RC2'
implementation "com.google.auto.service:auto-service:1.0-rc4"
kapt "com.google.auto.service:auto-service:1.0-rc4"
Sample Class:
@MyAnnotation
internal class Car
I got the TypeElement of this inside the process method
override fun process(annotations: MutableSet<out TypeElement>, roundEnv: RoundEnvironment): Boolean {
roundEnv.getElementsAnnotatedWith(MyAnnotation::class.java).forEach { classElement ->
if (classElement.kind != ElementKind.CLASS) {
error(...)
return true
}
classElement as TypeElement
But I don't know how to detect if the class has the "internal" modifier.
If I do: classElement.modifiers
I get this:
Any idea on how to detect the "internal" modifier?