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

name.remal.gradle_plugins.dsl.extensions.org.gradle.api.NamedDomainObjectCollection.kt Maven / Gradle / Ivy

package name.remal.gradle_plugins.dsl.extensions

import org.gradle.api.NamedDomainObjectCollection

operator fun  NamedDomainObjectCollection.get(type: Class): NamedDomainObjectCollection = withType(type)

operator fun NamedDomainObjectCollection<*>.contains(name: String): Boolean = null != findByName(name)
operator fun  NamedDomainObjectCollection.get(name: String): T = getByName(name)
operator fun  NamedDomainObjectCollection.get(type: Class, name: String): S = withType(type).getByName(name)


fun  NamedDomainObjectCollection.all(name: String, configureAction: (T) -> Unit) = all {
    if (name == namer.determineName(it)) {
        configureAction(it)
    }
}

fun  NamedDomainObjectCollection.all(type: Class, name: String, configureAction: (S) -> Unit) = withType(type).all(name, configureAction)

fun  NamedDomainObjectCollection.forEach(name: String, configureAction: (T) -> Unit) = forEach {
    if (name == namer.determineName(it)) {
        configureAction(it)
    }
}

fun  NamedDomainObjectCollection.forEach(type: Class, name: String, configureAction: (S) -> Unit) = withType(type).forEach(name, configureAction)