toInteger
Returns this integer as an Integer.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val value: Integer = Integer.fromLong(-42)
val nonPositiveInteger: NonPositiveInteger =
NonPositiveInteger.fromInteger(value)
val result: Integer = nonPositiveInteger.toInteger()
check(result == value)Content copied to clipboard
Calling from Java
Here's an example of calling this function from Java code:
final Integer value = Integer.fromLong(-42);
final NonPositiveInteger nonPositiveInteger =
NonPositiveInteger.fromInteger(value);
final Integer result = nonPositiveInteger.toInteger();
final boolean check = result.equals(value);
if (!check) throw new IllegalStateException("Check failed.");Content copied to clipboard