Reference

open class Reference<V>

Represents an object reference that may be reassigned.

Author

Lucas Bubner, 2024

Since

1.0.0-pre

Parameters

<V>

the type of the reference

Constructors

Link copied to clipboard
constructor()
Creates a new reference with a null value.
constructor(@Nullable value: V)
Creates a new reference with the given value.

Functions

Link copied to clipboard
open fun clear()
Clears the reference, setting it to null.
Link copied to clipboard
open fun <V> empty(): Reference<V>
Creates a new reference with a null value.
Link copied to clipboard
open fun equals(obj: Any): Boolean
Link copied to clipboard
open fun get(): V
Gets the value of the reference.
Link copied to clipboard
open fun getOrElse(other: V): V
Returns the value of the reference if it is not null, otherwise returns the given value.
Link copied to clipboard
open fun hashCode(): Int
Returns the hash code of the reference.
Link copied to clipboard
open fun ifNotPresent(runnable: Runnable)
Runs the runnable on the value of the reference if it is null.
Link copied to clipboard
open fun ifPresent(consumer: Consumer<V>)
Runs the consumer on the value of the reference if it is not null.
Link copied to clipboard
open fun ifPresentOrElse(consumer: Consumer<V>, runnable: Runnable)
Runs the consumer on the value of the reference if it is not null.
Link copied to clipboard
open fun isNotNull(): Boolean
Checks if the reference is not null.
Link copied to clipboard
open fun isNull(): Boolean
Checks if the reference is null.
Link copied to clipboard
open fun <V> of(@Nullable value: V): Reference<V>
Creates a new reference with the given value.
Link copied to clipboard
open fun require(): V
Gets the value of the reference.
Link copied to clipboard
open fun set(@Nullable value: V)
Sets the value of the reference.
Link copied to clipboard
open fun setIfNotPresent(@Nullable value: V)
Sets the value of the reference if it is not already set.
Link copied to clipboard
open fun setIfPresent(@Nullable value: V)
Sets the value of the reference if it is already set.
Link copied to clipboard
open fun toString(): String
Returns a string representation of the reference.