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

commonMain.com.bselzer.ktx.compose.ui.layout.merge.ComponentMerger.kt Maven / Gradle / Ivy

There is a newer version: 7.0.0
Show newest version
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