summaryrefslogtreecommitdiff
path: root/src/org/unitConverter/unit/FunctionalUnit.java
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2019-05-22 18:47:05 -0400
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2019-05-22 18:47:05 -0400
commit01b072b98fdd19a2d57afc15a4ee4a80d0bfc0cd (patch)
tree0b835f4196e0e34a9530e014352d89a41096ef97 /src/org/unitConverter/unit/FunctionalUnit.java
parent987fd8406d65505aedecd17e51216eb0ce393fbb (diff)
Added null checks to Unit's methods, including the new methods.
Diffstat (limited to 'src/org/unitConverter/unit/FunctionalUnit.java')
-rw-r--r--src/org/unitConverter/unit/FunctionalUnit.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/org/unitConverter/unit/FunctionalUnit.java b/src/org/unitConverter/unit/FunctionalUnit.java
index c2aae6d..e3db43a 100644
--- a/src/org/unitConverter/unit/FunctionalUnit.java
+++ b/src/org/unitConverter/unit/FunctionalUnit.java
@@ -16,6 +16,7 @@
*/
package org.unitConverter.unit;
+import java.util.Objects;
import java.util.function.DoubleUnaryOperator;
/**
@@ -38,6 +39,8 @@ final class FunctionalUnit extends AbstractUnit {
* base.
* @return a unit that uses the provided functions to convert.
* @since 2019-05-22
+ * @throws NullPointerException
+ * if any argument is null
*/
public static FunctionalUnit valueOf(final BaseUnit base, final DoubleUnaryOperator converterFrom,
final DoubleUnaryOperator converterTo) {
@@ -69,13 +72,15 @@ final class FunctionalUnit extends AbstractUnit {
* @param converterTo
* function that accepts a value expressed in the unit and returns that value expressed in the unit's
* base.
+ * @throws NullPointerException
+ * if any argument is null
* @since 2019-05-22
*/
private FunctionalUnit(final BaseUnit base, final DoubleUnaryOperator converterFrom,
final DoubleUnaryOperator converterTo) {
super(base);
- this.converterFrom = converterFrom;
- this.converterTo = converterTo;
+ this.converterFrom = Objects.requireNonNull(converterFrom, "converterFrom must not be null.");
+ this.converterTo = Objects.requireNonNull(converterTo, "converterTo must not be null.");
}
@Override