summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnits/unit/Unit.java
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2025-05-30 19:48:42 -0500
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2025-05-30 19:54:19 -0500
commite86fb71e1665cb9e8511bafd54df0fb8cbca5adc (patch)
treecbc3aa8c4a4848c0a0f9e332fcab576ad0c10e27 /src/main/java/sevenUnits/unit/Unit.java
parent8df414ced2018e685f034424c3d8c7813d18805c (diff)
Remove Unitlike/MultiUnit
I ended up never using this code - it was simpler to just use lists of units and values. Making a whole new object for lists of units, and an abstract class for things that convert things other than doubles, is needlessly complicated, and doesn't solve any major issues. For example, I still need to store each Unitlike type in a different collection, because it will have a different type.
Diffstat (limited to 'src/main/java/sevenUnits/unit/Unit.java')
-rw-r--r--src/main/java/sevenUnits/unit/Unit.java52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/main/java/sevenUnits/unit/Unit.java b/src/main/java/sevenUnits/unit/Unit.java
index 59e928a..d25b362 100644
--- a/src/main/java/sevenUnits/unit/Unit.java
+++ b/src/main/java/sevenUnits/unit/Unit.java
@@ -137,15 +137,6 @@ public abstract class Unit implements Nameable {
}
/**
- * @return this unit as a {@link Unitlike}
- * @since 2020-09-07
- */
- public final Unitlike<Double> asUnitlike() {
- return Unitlike.fromConversionFunctions(this.getBase(),
- this::convertFromBase, this::convertToBase, this.getNameSymbol());
- }
-
- /**
* Checks if a value expressed in this unit can be converted to a value
* expressed in {@code other}
*
@@ -161,21 +152,6 @@ public abstract class Unit implements Nameable {
}
/**
- * Checks if a value expressed in this unit can be converted to a value
- * expressed in {@code other}
- *
- * @param other unit or unitlike form to test with
- * @return true if they are compatible
- * @since 2019-01-13
- * @since v0.1.0
- * @throws NullPointerException if other is null
- */
- public final <W> boolean canConvertTo(final Unitlike<W> other) {
- Objects.requireNonNull(other, "other must not be null.");
- return Objects.equals(this.getBase(), other.getBase());
- }
-
- /**
* Converts from a value expressed in this unit's base unit to a value
* expressed in this unit.
* <p>
@@ -226,34 +202,6 @@ public abstract class Unit implements Nameable {
}
/**
- * Converts a value expressed in this unit to a value expressed in
- * {@code other}.
- *
- * @implSpec If conversion is possible, this implementation returns
- * {@code other.convertFromBase(this.convertToBase(value))}.
- * Therefore, overriding either of those methods will change the
- * output of this method.
- *
- * @param other unitlike form to convert to
- * @param value value to convert
- * @param <W> type of value to convert to
- * @return converted value
- * @since 2020-09-07
- * @throws IllegalArgumentException if {@code other} is incompatible for
- * conversion with this unit (as tested by
- * {@link Unit#canConvertTo}).
- * @throws NullPointerException if other is null
- */
- public final <W> W convertTo(final Unitlike<W> other, final double value) {
- Objects.requireNonNull(other, "other must not be null.");
- if (this.canConvertTo(other))
- return other.convertFromBase(this.convertToBase(value));
- else
- throw new IllegalArgumentException(
- String.format("Cannot convert from %s to %s.", this, other));
- }
-
- /**
* Converts from a value expressed in this unit to a value expressed in this
* unit's base unit.
* <p>