EnumFromValue

abstract class EnumFromValue<InternalValue, E : Enum<E>>(default: E)(source)

Abstract class for enum wrappers that wrap over primitive enum values. The companion object of the enum wrapper should implement this abstract class.

fromValueOrNull should be implemented to indicate how the given value should be parsed to its enum entry equivalent.

Since

0.0.1

Parameters

InternalValue

The internal value representation of the enum.

E

The enum.

default

The default value to be used for fromValue.

Inheritors

Constructors

Link copied to clipboard
constructor(default: E)

Functions

Link copied to clipboard

Gets the E representation of value, or default if no such representation exists.

Link copied to clipboard
fun fromValueOrElse(value: InternalValue, default: E): E

Gets the E representation of value, or default if no such representation exists.

Link copied to clipboard
abstract fun fromValueOrNull(value: InternalValue): E?

Gets the E representation of value, or null if no such representation exists.

Link copied to clipboard

Checks if an enum entry with the given value exists.

Link copied to clipboard

Gets the E representation of value, or throws an IllegalArgumentException if no such representation exists.