diff options
author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2019-05-22 18:47:05 -0400 |
---|---|---|
committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2019-05-22 18:47:05 -0400 |
commit | 01b072b98fdd19a2d57afc15a4ee4a80d0bfc0cd (patch) | |
tree | 0b835f4196e0e34a9530e014352d89a41096ef97 /src/org/unitConverter/unit/FunctionalUnit.java | |
parent | 987fd8406d65505aedecd17e51216eb0ce393fbb (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.java | 9 |
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 |