equals
Returns true if the other object is a NonZeroInteger representing the same numeric value as this one, or returns false otherwise.
This function follows the contract of Any.equals.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
val x: NonZeroInteger = NonZeroInteger.fromLong(42)
val y: NonZeroInteger = NonZeroInteger.parse("+00042")
check(x == y)
check(x.hashCode() == y.hashCode())
val z: NonZeroInteger = NonZeroInteger.fromLong(-42)
check(x != z)
check(x.hashCode() != z.hashCode())Content copied to clipboard
Calling from Java
Here's an example of calling this function from Java code:
final NonZeroInteger x = NonZeroInteger.fromLong(42L);
final NonZeroInteger y = NonZeroInteger.parse("+00042");
final boolean equality = x.equals(y) && x.hashCode() == y.hashCode();
if (!equality) throw new IllegalStateException("Check failed.");
final NonZeroInteger z = NonZeroInteger.fromLong(-42L);
final boolean inequality =
!x.equals(z) && x.hashCode() != z.hashCode();
if (!inequality) throw new IllegalStateException("Check failed.");Content copied to clipboard