Last active
June 8, 2017 12:25
-
-
Save tarek360/0145a95b7b32eeb46255704861e5ab1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.auto.service.AutoService | |
import com.tarek30.annotation.EasyJSON | |
import javax.annotation.processing.AbstractProcessor | |
import javax.annotation.processing.ProcessingEnvironment | |
import javax.annotation.processing.Processor | |
import javax.annotation.processing.RoundEnvironment | |
import javax.lang.model.SourceVersion | |
import javax.lang.model.element.TypeElement | |
@AutoService(Processor::class) | |
class EasyJSONProcessor : AbstractProcessor() { | |
@Synchronized override fun init(processingEnv: ProcessingEnvironment) { | |
super.init(processingEnv) | |
} | |
override fun getSupportedAnnotationTypes(): Set<String> { | |
return setOf(EasyJSON::class.java.canonicalName) | |
} | |
override fun getSupportedSourceVersion(): SourceVersion { | |
return SourceVersion.latestSupported() | |
} | |
override fun process(annotations: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean { | |
// Your annotated classes | |
val annotatedClasses = | |
roundEnv.getElementsAnnotatedWith(EasyJSON::class.java) | |
// Filter annotated classes which is defined | |
// with @Target(AnnotationTarget.CLASS) | |
.filterIsInstance<TypeElement>() | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment