orNull
Creates an instance of Zero from the specified number, or returns null
if the number is other than zero.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val number: Byte = 0
val zero: Zero? = Zero.orNull(number)
assertNotNull(zero)
This function is not available from Java code due to its non-explicit support for nullable types.
See the orThrow function for throwing an exception instead of returning null
in case of invalid number.
Creates an instance of Zero from the specified number, or returns null
if the number is other than zero.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val number: Short = 0
val zero: Zero? = Zero.orNull(number)
assertNotNull(zero)
This function is not available from Java code due to its non-explicit support for nullable types.
See the orThrow function for throwing an exception instead of returning null
in case of invalid number.
Creates an instance of Zero from the specified number, or returns null
if the number is other than zero.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val zero: Zero? = Zero.orNull(0)
assertNotNull(zero)
This function is not available from Java code due to its non-explicit support for nullable types.
See the orThrow function for throwing an exception instead of returning null
in case of invalid number.
Creates an instance of Zero from the specified number, or returns null
if the number is other than zero.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val zero: Zero? = Zero.orNull(0L)
assertNotNull(zero)
This function is not available from Java code due to its non-explicit support for nullable types.
See the orThrow function for throwing an exception instead of returning null
in case of invalid number.
Creates an instance of Zero from the specified number, or returns null
if the number is other than zero.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val zero: Zero? = Zero.orNull(0f)
assertNotNull(zero)
This function is not available from Java code due to its non-explicit support for nullable types.
See the orThrow function for throwing an exception instead of returning null
in case of invalid number.
Creates an instance of Zero from the specified number, or returns null
if the number is other than zero.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val zero: Zero? = Zero.orNull(0.0)
assertNotNull(zero)
This function is not available from Java code due to its non-explicit support for nullable types.
See the orThrow function for throwing an exception instead of returning null
in case of invalid number.
Creates an instance of Zero from the specified text, or returns null
if the text is an invalid representation of zero.
The text is a valid representation if it matches the following pattern: ^0+(?:\.0+)?$
.
Pattern symbols
Here's the explanation associated to each symbol used in this pattern:
^
Beginning. Matches the beginning of the string, or the beginning of a line if the multiline flag (m) is enabled.0
Character. Matches a "0" character (char code 48).+
Quantifier. Match 1 or more of the preceding token.(?:)
Non-capturing group. Groups multiple tokens together without creating a capture group.\.
Escaped character. Matches a "." character (char code 46).?
Quantifier. Match between 0 and 1 of the preceding token.$
End. Matches the end of the string, or the end of a line if the multiline flag (m) is enabled.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
listOf("0", "000", "0.0", "0.000", "000.0", "000.000")
.map(Zero.Companion::orNull)
.forEach(::assertNotNull)
This function is not available from Java code due to its non-explicit support for nullable types.
See the orThrow function for throwing an exception instead of returning null
in case of invalid text.