OptionalBoolean
Represents a value that encapsulate the optional and value state of a Boolean in the Discord API. Specifically:
Missing - a Boolean field that was not present in the serialized entity.
Value - a Boolean field that was assigned a non-null value in the serialized entity.
Note that there is no nullable variant present. Use Boolean? or
OptionalBoolean?
for this case instead.
These classes are fully (de)serializable with kotlinx.serialization.
Note that kotlinx.serialization does not call serializers for values that are not present in the serialized format. Optional
fields should have a default value of OptionalBoolean.Missing
:
@Serializable
class DiscordUser(
val id: Boolean,
val username: String,
val bot: OptionalBoolean = OptionalBoolean.Missing
)
Inheritors
Types
Represents a Boolean field that was not present in the serialized entity.
Represents a field that was assigned a non-null value in the serialized entity. Equality and hashcode is implemented through its value.
Properties
returns null
if this is null
, calls OptionalBoolean.asNullable otherwise.
returns null
if this is null
or OptionalBoolean.Missing, calls OptionalBoolean.Value.value otherwise.
Functions
returns default if this is null
, calls OptionalBoolean.asNullable otherwise.