OptionalVariable.Value

class OptionalVariable.Value<T : Any?> : OptionalVariable


An implementation of OptionalVariable representing a "defined" value.

This value will be included in the serial form, even if the value is null.

Summary

Public constructors

<T : Any?> Value(value: T)

Public functions

open operator Boolean
equals(other: Any?)

Compares this object with another object for equality.

open Int

Returns the hash code of the encapsulated value, or 0 if the encapsulated value is null.

open String

Returns the Object.toString() result of the encapsulated value, or "null" if the encapsulated value is null.

open T

Returns the value encapsulated by this OptionalVariable, which may be null.

open T

Returns the value encapsulated by this OptionalVariable, which may be null, but never throws an exception.

Public properties

T

the value encapsulated by this OptionalVariable.

Public constructors

Value

<T : Any?> Value(value: T)

Public functions

equals

open operator fun equals(other: Any?): Boolean

Compares this object with another object for equality.

Parameters
other: Any?

The object to compare to this for equality.

Returns
Boolean

true if, and only if, the other object is an instance of Value whose encapsulated value compares equal to this object's encapsulated value using the == operator.

hashCode

open fun hashCode(): Int

Returns the hash code of the encapsulated value, or 0 if the encapsulated value is null.

toString

open fun toString(): String

Returns the Object.toString() result of the encapsulated value, or "null" if the encapsulated value is null.

The string representation is not guaranteed to be stable and may change without notice at any time. Therefore, the only recommended usage of the returned string is debugging and/or logging. Namely, parsing the returned string or storing the returned string in non-volatile storage should generally be avoided in order to be robust in case that the string representation changes.

valueOrNull

open fun valueOrNull(): T

Returns the value encapsulated by this OptionalVariable, which may be null.

valueOrThrow

open fun valueOrThrow(): T

Returns the value encapsulated by this OptionalVariable, which may be null, but never throws an exception.

Public properties

value

val value: T

the value encapsulated by this OptionalVariable.