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; }