1 package de
.xn__ho_hia
.quality
.null_analysis
;
3 import java
.math
.BigInteger
;
5 import org
.eclipse
.jdt
.annotation
.NonNull
;
8 * Utility class to work with @NonNull match operations.
10 public final class NullsafeMath
{
15 * @return A @NonNull {@link BigInteger}
17 public static @NonNull BigInteger
asBigInteger(final long value
) {
18 return Nullsafe
.nonNull(BigInteger
.valueOf(value
));
24 * @return A @NonNull {@link Long}
26 public static @NonNull Long
asLong(final long value
) {
27 return Nullsafe
.nonNull(Long
.valueOf(value
));
32 * The first value to add
34 * The second value to add
35 * @return The sum of both values as a @NonNull {@link BigInteger}
37 public static @NonNull BigInteger
addNullsafe(final BigInteger first
, final BigInteger second
) {
38 return Nullsafe
.nonNull(first
.add(second
));
43 * The first value to subtract
45 * The second value to subtract
46 * @return The difference of both values as a @NonNull {@link BigInteger}
48 public static @NonNull BigInteger
subtractNullsafe(final BigInteger first
, final BigInteger second
) {
49 return Nullsafe
.nonNull(first
.subtract(second
));
54 * The first value to divide
56 * The second value to divide
57 * @return The division of both values as a @NonNull {@link BigInteger}
59 public static @NonNull BigInteger
divideNullsafe(final BigInteger first
, final BigInteger second
) {
60 return Nullsafe
.nonNull(first
.divide(second
));
65 * The first value to multiply
67 * The second value to multiply
68 * @return The multiplication of both values as a @NonNull {@link BigInteger}
70 public static @NonNull BigInteger
multiplyNullsafe(final BigInteger first
, final BigInteger second
) {
71 return Nullsafe
.nonNull(first
.multiply(second
));