requireNull

fun requireNull(value: Any?)

Requires that the given value is null, throwing IllegalArgumentException if it is not.

This function is the inverse of requireNotNull. On return, value is smart-cast to null.

Parameters

value

The value to check for nullness

Throws


inline fun <T : Any> requireNull(value: T?, lazyMessage: (T) -> String)

Requires that the given value is null, throwing IllegalArgumentException with the given message if it is not.

This function is the inverse of requireNotNull. On return, value is smart-cast to null.

The lazyMessage lambda is only evaluated if value is not null.

Parameters

T

The type of the value to check

value

The value to check for nullness

lazyMessage

If value is not null, it is passed to this lambda to produce an exception message

Throws