From 17493ae625e960d2000c1f40d6ba9f2813ea9171 Mon Sep 17 00:00:00 2001 From: iTitus Date: Tue, 19 Oct 2021 19:16:51 +0200 Subject: [PATCH] fix errors in initializer --- src/main/java/io/github/ititus/si/unit/AlternateUnit.java | 4 +--- src/main/java/io/github/ititus/si/unit/ConvertedUnit.java | 4 +--- src/main/java/io/github/ititus/si/unit/PrefixUnit.java | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/ititus/si/unit/AlternateUnit.java b/src/main/java/io/github/ititus/si/unit/AlternateUnit.java index 0275b18..0d51ffe 100644 --- a/src/main/java/io/github/ititus/si/unit/AlternateUnit.java +++ b/src/main/java/io/github/ititus/si/unit/AlternateUnit.java @@ -38,9 +38,7 @@ public > UnitConverter getConverterTo(Unit unit) { @Override @SuppressWarnings("unchecked") public > Unit as(T type) { - if (!isCommensurableWith(type)) { - throw new NotCommensurableException(); - } else if (getType().equals(type)) { + if (getType().equals(type)) { return (Unit) this; } diff --git a/src/main/java/io/github/ititus/si/unit/ConvertedUnit.java b/src/main/java/io/github/ititus/si/unit/ConvertedUnit.java index 85b0971..6ae939b 100644 --- a/src/main/java/io/github/ititus/si/unit/ConvertedUnit.java +++ b/src/main/java/io/github/ititus/si/unit/ConvertedUnit.java @@ -48,9 +48,7 @@ public > UnitConverter getConverterTo(Unit unit) { @Override @SuppressWarnings("unchecked") public > Unit as(T type) { - if (!isCommensurableWith(type)) { - throw new NotCommensurableException(); - } else if (getType().equals(type)) { + if (getType().equals(type)) { return (Unit) this; } diff --git a/src/main/java/io/github/ititus/si/unit/PrefixUnit.java b/src/main/java/io/github/ititus/si/unit/PrefixUnit.java index d680c47..b584115 100644 --- a/src/main/java/io/github/ititus/si/unit/PrefixUnit.java +++ b/src/main/java/io/github/ititus/si/unit/PrefixUnit.java @@ -52,9 +52,7 @@ public > UnitConverter getConverterTo(Unit unit) { @Override @SuppressWarnings("unchecked") public > Unit as(T type) { - if (!isCommensurableWith(type)) { - throw new NotCommensurableException(); - } else if (getType().equals(type)) { + if (getType().equals(type)) { return (Unit) this; }