se.ansman.kotshi.ksp.generators.ObjectAdapterGenerator.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compiler Show documentation
Show all versions of compiler Show documentation
An annotations processor that generates Moshi adapters from Kotlin data classes
package se.ansman.kotshi.ksp.generators
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
import com.google.devtools.ksp.symbol.ClassKind
import com.google.devtools.ksp.symbol.KSClassDeclaration
import se.ansman.kotshi.model.GeneratableJsonAdapter
import se.ansman.kotshi.model.GlobalConfig
import se.ansman.kotshi.model.ObjectJsonAdapter
class ObjectAdapterGenerator(
environment: SymbolProcessorEnvironment,
element: KSClassDeclaration,
globalConfig: GlobalConfig,
resolver: Resolver
) : AdapterGenerator(environment, element, globalConfig, resolver) {
init {
require(element.classKind == ClassKind.OBJECT)
}
override fun getGeneratableJsonAdapter(): GeneratableJsonAdapter =
ObjectJsonAdapter(
targetPackageName = targetClassName.packageName,
targetSimpleNames = targetClassName.simpleNames,
polymorphicLabels = polymorphicLabels,
)
}