EnumPreferenceDelegate

class EnumPreferenceDelegate<T>(getValue: () -> T?, getEffectiveValue: () -> T, getIsEffective: () -> Boolean, updateValue: (T?) -> Unit, val supportedValues: List<T>) : PreferenceDelegate<T> , EnumPreference<T>

Constructors

Link copied to clipboard
constructor(getValue: () -> T?, getEffectiveValue: () -> T, getIsEffective: () -> Boolean, updateValue: (T?) -> Unit, supportedValues: List<T>)

Properties

Link copied to clipboard
open override val effectiveValue: T

The value that will be effectively used by the navigator if preferences are submitted as they are.

Link copied to clipboard
open override val isEffective: Boolean

If this preference will be effectively used by the navigator if preferences are submitted as they are.

Link copied to clipboard
open override val supportedValues: List<T>

List of valid values for this preference.

Link copied to clipboard
open override val value: T?

The current value of the preference.

Functions

Link copied to clipboard
fun <T> Preference<T>.clear()

Unset the preference.

Link copied to clipboard

Returns a new preference with its boolean value flipped.

Link copied to clipboard
fun <T, V> Preference<T>.map(from: (T) -> V, to: (V) -> T): Preference<V>

Creates a new Preference object wrapping the receiver and converting its value from and to the target type V.

fun <T, V> EnumPreference<T>.map(from: (T) -> V, to: (V) -> T, supportedValues: (List<T>) -> List<V> = { it.map(from) }): EnumPreference<V>

Creates a new EnumPreference object wrapping the receiver and converting its value and supportedValues, from and to the target type V.

Link copied to clipboard

Creates a new EnumPreference object wrapping the receiver and transforming its supported values with transform.

Link copied to clipboard
open override fun set(value: T?)

Set the preference to value. A null value means unsetting the preference.

Link copied to clipboard

Toggle the preference value. A default value is taken as the initial one if the preference is currently unset.

Link copied to clipboard
fun <T> EnumPreference<T>.withSupportedValues(vararg supportedValues: T): EnumPreference<T>
fun <T> Preference<T>.withSupportedValues(vararg supportedValues: T): EnumPreference<T>
fun <T> Preference<T>.withSupportedValues(supportedValues: List<T>): EnumPreference<T>

Creates a new EnumPreference object wrapping the receiver with the provided supportedValues.