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

gsonpath.adapter.standard.StandardAdapterFactory.kt Maven / Gradle / Ivy

Go to download

An annotation processor which generates Type Adapters for the Google Gson library

The newest version!
package gsonpath.adapter.standard

import gsonpath.LazyFactoryMetadata
import gsonpath.adapter.AdapterFactory
import gsonpath.adapter.AdapterGenerationResult
import gsonpath.adapter.util.AdapterFactoryUtil.getAnnotatedModelElements
import gsonpath.annotation.AutoGsonAdapter
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,
            lazyFactoryMetadata: LazyFactoryMetadata,
            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, lazyFactoryMetadata)
                }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy