ysny.karibu-tools.karibu-tools.0.20.source-code.Renderers.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of karibu-tools Show documentation
Show all versions of karibu-tools Show documentation
Karibu-Tools: The Vaadin Missing Utilities
package com.github.mvysny.kaributools
import com.vaadin.flow.data.renderer.BasicRenderer
import com.vaadin.flow.data.renderer.Renderer
import com.vaadin.flow.function.ValueProvider
import java.lang.reflect.Field
private val _BasicRenderer_valueProvider: Field by lazy(LazyThreadSafetyMode.PUBLICATION) {
val javaField: Field = BasicRenderer::class.java.getDeclaredField("valueProvider")
javaField.isAccessible = true
javaField
}
/**
* Returns the [ValueProvider] set to [BasicRenderer].
*/
@Suppress("UNCHECKED_CAST", "ConflictingExtensionProperty")
public val BasicRenderer.valueProvider: ValueProvider
get() = _BasicRenderer_valueProvider.get(this) as ValueProvider
private val _Renderer_template: Field by lazy(LazyThreadSafetyMode.PUBLICATION) {
val templateF: Field = Renderer::class.java.getDeclaredField("template")
templateF.isAccessible = true
templateF
}
/**
* Returns the Polymer Template set to the [Renderer]. Returns "" for Vaadin 24+ since PolymerTemplates
* are no longer supported.
*/
public val Renderer<*>.template: String
get() {
if (VaadinVersion.get.major >= 24) return ""
val template: String? = _Renderer_template.get(this) as String?
return template ?: ""
}