commonMain.com.bselzer.ktx.compose.ui.layout.merge.ComponentMerger.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compose-ui-layout-jvm Show documentation
Show all versions of compose-ui-layout-jvm Show documentation
Base extensions for laying out Compose Multiplatform UI.
package com.bselzer.ktx.compose.ui.layout.merge
interface ComponentMerger {
/**
* The default value.
*/
val default: T
/**
* Determines whether the [value] is the exact reference of the [default].
*/
fun isDefault(value: T) = value == default
/**
* Merges the [first] object with the [second] object by taking the [second] object if it is not the [default], otherwise taking the [first] object.
*/
fun safeMerge(first: T, second: T) = first.safeMerge(second, default)
/**
* Merges the [first] object with the [second] object by taking the [second] object if it is not the [default], otherwise taking the [first] object.
*/
fun nullMerge(first: T?, second: T?) = first.safeMerge(second, default)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy