public open class RemoteEnum<T : Enum<T>>(
internal val intValue: RemoteInt,
internal val enumEntries: EnumEntries<T>,
) : BaseRemoteState<T>(RemoteStateInstanceKey())
A class representing a remote enum value.
RemoteInt internally stores its state as a RemoteInt, using the Enum ordinal.
Properties
cacheKey
override val cacheKey: RemoteStateCacheKey
constantValueOrNull
public override val constantValueOrNull: T?
asEncoded
override val asEncoded: RemoteInt
ordinal
public val ordinal: RemoteInt
Converts this RemoteEnum to its underlying RemoteInt representation, using the Enum ordinal.
Return
The RemoteInt that holds the enum's value.
Functions
toRemoteString
public fun toRemoteString(mapping: (T) -> RemoteString = { it.toString().rs }): RemoteString
Converts this RemoteEnum to a RemoteString representation.
This method maps each possible enum entry to a string using the provided mapping function. At runtime, the RemoteString will resolve to the string corresponding to the current value of the enum. Defaults to calling Any.toString on the enum entry.
Parameters
| mapping | A function that defines how each enum constant should be converted to a RemoteString. |
Return
A RemoteString that tracks the string value of this enum.
toRemoteInt
public fun toRemoteInt(mapping: (T) -> RemoteInt): RemoteInt
Converts this RemoteEnum to a RemoteInt representation using a provided mapping.
This method maps each possible enum entry to a RemoteInt using the provided mapping function. At runtime, the resulting RemoteInt will resolve to the value corresponding to the current state of the enum.
Parameters
| mapping | A function that defines how each enum constant should be converted to a RemoteInt. |
Return
A RemoteInt that tracks the integer value associated with this enum.
Members
Companion
public companion object
Functions
invoke
public inline operator fun <reified T : Enum<T>> invoke(value: T): RemoteEnum<T>
Creates a RemoteEnum from a literal constant.
Parameters
| value | The constant Enum value. |
Return
A RemoteEnum representing the constant enum.
createNamedRemoteEnum
public inline fun <reified T : Enum<T>> createNamedRemoteEnum(
name: String,
defaultValue: T,
domain: RemoteState.Domain = RemoteState.Domain.User,
): RemoteEnum<T>
Creates a named RemoteEnum with an initial value.
Parameters
| name | The unique name for this remote enum. |
| domain | The domain of the named enum (defaults to RemoteState.Domain.User). |
| defaultValue | The initial Enum value for the named remote enum. |
Return
A RemoteEnum representing the named enum.