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

com.autonomousapps.kit.gradle.Imports.kt Maven / Gradle / Ivy

The newest version!
package com.autonomousapps.kit.gradle

import com.autonomousapps.kit.render.Scribe

public class Imports(
  private val imports: MutableList,
) {

  public constructor(vararg imports: Import) : this(imports.toMutableList())

  init {
    require(imports.isNotEmpty()) { "Imports must not be empty" }
  }

  public fun render(scribe: Scribe): String {
    return scribe.line { s ->
      imports.forEach { it.render(s) }
    }
  }

  public companion object {
    @JvmStatic
    public fun of(vararg imports: String): Imports {
      return Imports(imports.mapTo(mutableListOf()) { Import(it) })
    }

    @JvmStatic
    public fun of(imports: Iterable): Imports {
      return Imports(imports.mapTo(mutableListOf()) { Import(it) })
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy