diff options
Diffstat (limited to 'src/org/unitConverter/unit/Unit.java')
-rwxr-xr-x | src/org/unitConverter/unit/Unit.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/org/unitConverter/unit/Unit.java b/src/org/unitConverter/unit/Unit.java index 2ac107e..54f0ab5 100755 --- a/src/org/unitConverter/unit/Unit.java +++ b/src/org/unitConverter/unit/Unit.java @@ -48,6 +48,8 @@ public interface Unit { * base. * @return a unit that uses the provided functions to convert. * @since 2019-05-22 + * @throws NullPointerException + * if any argument is null */ public static Unit fromConversionFunctions(final BaseUnit base, final DoubleUnaryOperator converterFrom, final DoubleUnaryOperator converterTo) { @@ -62,8 +64,11 @@ public interface Unit { * @return true if the units are compatible * @since 2019-01-13 * @since v0.1.0 + * @throws NullPointerException + * if other is null */ default boolean canConvertTo(final Unit other) { + Objects.requireNonNull(other, "other must not be null."); return Objects.equals(this.getBase(), other.getBase()); } @@ -97,8 +102,11 @@ public interface Unit { * @throws IllegalArgumentException * if {@code other} is incompatible for conversion with this unit (as tested by * {@link Unit#canConvertTo}). + * @throws NullPointerException + * if other is null */ default double convertTo(final Unit other, final double value) { + Objects.requireNonNull(other, "other must not be null."); if (this.canConvertTo(other)) return other.convertFromBase(this.convertToBase(value)); else |