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

spi.strategy.KotlinCodeGenerationStrategyBase.kt Maven / Gradle / Ivy

There is a newer version: 0.1.0
Show newest version
package io.toolisticon.kotlin.generation.spi.strategy

import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi
import io.toolisticon.kotlin.generation.spi.KotlinCodeGenerationContext
import io.toolisticon.kotlin.generation.spi.KotlinCodeGenerationSpi
import io.toolisticon.kotlin.generation.spi.KotlinCodeGenerationStrategy
import kotlin.reflect.KClass

/**
 * Abstract base implementation of [KotlinCodeGenerationStrategy] for convenience setting of generic types.
 */
@ExperimentalKotlinPoetApi
abstract class KotlinCodeGenerationStrategyBase, INPUT : Any, SPEC : Any>(
  override val contextType: KClass,
  override val inputType: KClass,
  override val specType: KClass,
  override val order: Int = KotlinCodeGenerationSpi.DEFAULT_ORDER,
) : KotlinCodeGenerationStrategy {

  abstract override fun invoke(context: CONTEXT, input: INPUT): SPEC
  override fun test(context: CONTEXT, input: Any): Boolean = super.test(context, input)

  override val name: String by lazy { javaClass.name }
  override fun toString(): String = name
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy