From 7257fbd189c779105c9393458a2e0cdf06e285f7 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Fri, 7 Mar 2025 11:23:29 -0500 Subject: convertToMulti: Compare unit bases to this.base This is a necessary precondition for the conversion methods used later on in convertToMutliple, and it is simpler than the existing method. I can also be sure it works, due to the tests I just wrote. --- src/main/java/sevenUnits/unit/LinearUnitValue.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/sevenUnits/unit/LinearUnitValue.java b/src/main/java/sevenUnits/unit/LinearUnitValue.java index a8848fc..e239b49 100644 --- a/src/main/java/sevenUnits/unit/LinearUnitValue.java +++ b/src/main/java/sevenUnits/unit/LinearUnitValue.java @@ -126,11 +126,10 @@ public final class LinearUnitValue { final List others) { if (others.size() < 1) throw new IllegalArgumentException("Must have at least one unit"); - final ObjectProduct unitBase = others.get(0).getBase(); for (final LinearUnit unit : others) { - if (!unitBase.equals(unit.getBase())) + if (!Objects.equals(this.unit.getBase(), unit.getBase())) throw new IllegalArgumentException( - "All units must have the same base."); + "All provided units must have the same base as the value."); } LinearUnitValue remaining = this; -- cgit v1.2.3