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

gsonpath.adapter.enums.EnumAdapterFactory.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.enums

import gsonpath.LazyFactoryMetadata
import gsonpath.adapter.AdapterFactory
import gsonpath.adapter.AdapterGenerationResult
import gsonpath.adapter.util.AdapterFactoryUtil.getAnnotatedModelElements
import gsonpath.annotation.EnumGsonAdapter
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 EnumAdapterFactory : AdapterFactory {

    override fun generateGsonAdapters(
            env: RoundEnvironment,
            logger: Logger,
            lazyFactoryMetadata: LazyFactoryMetadata,
            annotations: Set,
            dependencies: Dependencies): List {

        return getAnnotatedModelElements(env, annotations, listOf(ElementKind.ENUM))
                .onEach { logger.printMessage("Generating TypeAdapter (${it.element})") }
                .map {
                    dependencies.enumGsonAdapterGenerator.handle(it.element, it.annotation, lazyFactoryMetadata)
                }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy