toInteger

Returns this integer as an Integer.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val nonZeroInteger: NonZeroInteger = NonZeroInteger.fromLong(42)
val result: Integer = nonZeroInteger.toInteger()
check(result == Integer.fromLong(42))

Calling from Java

Here's an example of calling this function from Java code:

final NonZeroInteger nonZeroInteger = NonZeroInteger.fromLong(42L);
final Integer result = nonZeroInteger.toInteger();
final boolean check = result.equals(Integer.fromLong(42L));
if (!check) throw new IllegalStateException("Check failed.");