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

spec.KotlinPropertySpec.kt Maven / Gradle / Ivy

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

import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi
import com.squareup.kotlinpoet.PropertySpec
import com.squareup.kotlinpoet.TypeName
import io.toolisticon.kotlin.generation.poet.KDoc
import io.toolisticon.kotlin.generation.poet.PropertySpecSupplier
import kotlin.reflect.KClass

/**
 * Represents a property.
 */
@ExperimentalKotlinPoetApi
data class KotlinPropertySpec(
  private val spec: PropertySpec
) : KotlinGeneratorSpec,
  KotlinPropertySpecSupplier,
  KotlinDocumentableSpec {

  val name: String get() = spec.name

  val type: TypeName get() = spec.type

  val mutable: Boolean get() = spec.mutable

  override fun  tag(type: KClass): T? = get().tag(type)
  override val kdoc: KDoc get() = KDoc(spec.kdoc)

  override fun spec(): KotlinPropertySpec = this
  override fun get(): PropertySpec = spec
}

/**
 * Marks the builder and the spec so they are interchangeable.
 */
@ExperimentalKotlinPoetApi
interface KotlinPropertySpecSupplier : KotlinGeneratorSpecSupplier, PropertySpecSupplier {
  override fun get(): PropertySpec = spec().get()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy