create

Creates a StrictlyNegativeDouble from the specified number, which may involve rounding or truncation, or throws an IllegalArgumentException if the number is greater than or equals zero.


Calling from Kotlin

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

val number: Number = -23
val isSuccess: Boolean = try {
StrictlyNegativeDouble.create(number)
true
} catch (exception: IllegalArgumentException) {
false
}
assertTrue(isSuccess)

Calling from Java

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

final Number number = -23;
boolean isSuccess;
try {
StrictlyNegativeDouble.Companion.create(number);
isSuccess = true;
} catch (final IllegalArgumentException exception) {
isSuccess = false;
}
Assertions.assertTrue(isSuccess);

You can use the StrictlyNegativeDouble.Companion.createOrNull for returning null instead of throwing an exception in case of invalid number.