support.SuppressAnnotation.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-code-generation Show documentation
Show all versions of kotlin-code-generation Show documentation
Wrapping core components for kotlin code generation with kotlin-poet.
The newest version!
package io.toolisticon.kotlin.generation.support
import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi
import com.squareup.kotlinpoet.joinToCode
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotation
import io.toolisticon.kotlin.generation.poet.FormatSpecifier.asCodeBlock
import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpec
import io.toolisticon.kotlin.generation.spec.KotlinAnnotationSpecSupplier
/**
* Builder to create a `@Suppress` annotation.
*/
@ExperimentalKotlinPoetApi
data class SuppressAnnotation(val names: List = emptyList()) : KotlinAnnotationSpecSupplier {
constructor(name: String) : this(listOf(name))
operator fun plus(name: String) = copy(names = (names + name).distinct())
override fun spec(): KotlinAnnotationSpec = buildAnnotation(Suppress::class) {
addMember(names.distinct().sorted().map { it.asCodeBlock() }.joinToCode())
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy