gsonpath.adapter.standard.StandardAdapterFactory.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gsonpath-compiler Show documentation
Show all versions of gsonpath-compiler Show documentation
An annotation processor which generates Type Adapters for the Google Gson library
package gsonpath.adapter.standard
import gsonpath.AutoGsonAdapter
import gsonpath.adapter.AdapterFactory
import gsonpath.adapter.AdapterGenerationResult
import gsonpath.adapter.util.AdapterFactoryUtil.getAnnotatedModelElements
import gsonpath.dependencies.Dependencies
import gsonpath.util.Logger
import javax.annotation.processing.RoundEnvironment
import javax.lang.model.element.ElementKind
import javax.lang.model.element.TypeElement
object StandardAdapterFactory : AdapterFactory {
override fun generateGsonAdapters(
env: RoundEnvironment,
logger: Logger,
annotations: Set,
dependencies: Dependencies): List {
return getAnnotatedModelElements(env, annotations, listOf(ElementKind.CLASS, ElementKind.INTERFACE))
.onEach { logger.printMessage("Generating TypeAdapter (${it.element})") }
.map { dependencies.standardGsonAdapterGenerator.handle(it.element, it.annotation) }
}
}