commonMain.KindSelector.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of element Show documentation
Show all versions of element Show documentation
A collection of drawing/charting utilities
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