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

commonMain.KindSelector.kt Maven / Gradle / Ivy

There is a newer version: 0.19.1
Show newest version
package com.juul.krayon.element

public fun  ElementSelector.withKind(
    kind: String,
): ElementSelector = KindSelector(this, kind)

internal class KindSelector(
    val parent: ElementSelector,
    val kind: String,
) : ElementSelector {

    init {
        require(parent !is KindSelector) {
            "Elements do not support multiple kinds, so nesting kind selectors is almost definitely a bug."
        }
    }

    override fun trySelect(element: Element): E? =
        parent.trySelect(element).takeIf { element.kind == kind }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy