remove m-release-p target
[null-analysis.git] / src / main / java / de / xn__ho_hia / quality / null_analysis / NullsafeMath.java
blob44dd07de069c5b542911c9d6c4d5dbe66f4d41b7
1 package de.xn__ho_hia.quality.null_analysis;
3 import java.math.BigInteger;
5 import org.eclipse.jdt.annotation.NonNull;
7 /**
8 * Utility class to work with @NonNull match operations.
9 */
10 public final class NullsafeMath {
12 /**
13 * @param value
14 * The value to wrap
15 * @return A @NonNull {@link BigInteger}
17 public static @NonNull BigInteger asBigInteger(final long value) {
18 return Nullsafe.nonNull(BigInteger.valueOf(value));
21 /**
22 * @param value
23 * The value to wrap
24 * @return A @NonNull {@link Long}
26 public static @NonNull Long asLong(final long value) {
27 return Nullsafe.nonNull(Long.valueOf(value));
30 /**
31 * @param first
32 * The first value to add
33 * @param second
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));
41 /**
42 * @param first
43 * The first value to subtract
44 * @param second
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));
52 /**
53 * @param first
54 * The first value to divide
55 * @param second
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));
63 /**
64 * @param first
65 * The first value to multiply
66 * @param second
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));