summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2025-03-07 11:23:29 -0500
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2025-03-07 11:48:10 -0500
commit7257fbd189c779105c9393458a2e0cdf06e285f7 (patch)
tree1a28934c1381cdcf4d68809faa89db428043c4b9
parentdeb4a650caf9eb49d32810e573f22bbd77f0ca47 (diff)
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.
-rw-r--r--src/main/java/sevenUnits/unit/LinearUnitValue.java5
1 files changed, 2 insertions, 3 deletions
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<LinearUnit> others) {
if (others.size() < 1)
throw new IllegalArgumentException("Must have at least one unit");
- final ObjectProduct<BaseUnit> 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;