summaryrefslogtreecommitdiff
path: root/src/org/unitConverter/newUnits/BaseUnit.java
diff options
context:
space:
mode:
authorAdrien Hopkins <masterofnumbers17@gmail.com>2019-10-16 13:53:29 -0400
committerAdrien Hopkins <masterofnumbers17@gmail.com>2019-10-16 13:53:29 -0400
commit45286c30f96f152f821098d878ede64ecbabe48a (patch)
treea4920babba8be5802967f2be6d215416e95f3c06 /src/org/unitConverter/newUnits/BaseUnit.java
parent145f524f19b3d61cd12441c2f1a8de05d7dcfe60 (diff)
Added the LinearUnit to the new units definition.
Diffstat (limited to 'src/org/unitConverter/newUnits/BaseUnit.java')
-rw-r--r--src/org/unitConverter/newUnits/BaseUnit.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/org/unitConverter/newUnits/BaseUnit.java b/src/org/unitConverter/newUnits/BaseUnit.java
index 69e8b8b..b7577ff 100644
--- a/src/org/unitConverter/newUnits/BaseUnit.java
+++ b/src/org/unitConverter/newUnits/BaseUnit.java
@@ -51,6 +51,17 @@ public final class BaseUnit implements Unit {
this.symbol = Objects.requireNonNull(symbol, "symbol must not be null.");
}
+ /**
+ * Returns a {@code LinearUnit} with this unit as a base and a conversion factor of 1. This operation must be done
+ * in order to allow units to be created with operations.
+ *
+ * @return this unit as a {@code LinearUnit}
+ * @since 2019-10-16
+ */
+ public LinearUnit asLinearUnit() {
+ return LinearUnit.valueOf(this.getBase(), 1);
+ }
+
@Override
public double convertFromBase(final double value) {
return value;