summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnits
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/sevenUnits')
-rw-r--r--src/main/java/sevenUnits/unit/Unit.java14
-rw-r--r--src/main/java/sevenUnits/unit/UnitType.java34
2 files changed, 40 insertions, 8 deletions
diff --git a/src/main/java/sevenUnits/unit/Unit.java b/src/main/java/sevenUnits/unit/Unit.java
index b80ccbd..826b59b 100644
--- a/src/main/java/sevenUnits/unit/Unit.java
+++ b/src/main/java/sevenUnits/unit/Unit.java
@@ -24,7 +24,6 @@ import java.util.function.DoubleUnaryOperator;
import sevenUnits.utils.DecimalComparison;
import sevenUnits.utils.NameSymbol;
import sevenUnits.utils.Nameable;
-import sevenUnits.utils.NamedObjectProduct;
import sevenUnits.utils.ObjectProduct;
/**
@@ -191,7 +190,7 @@ public abstract class Unit implements Nameable {
*
* @implSpec This method is used by {@link #convertTo}, and its behaviour
* affects the behaviour of {@code convertTo}.
- *
+ *
* @param value value expressed in <b>base</b> unit
* @return value expressed in <b>this</b> unit
* @since 2018-12-22
@@ -207,7 +206,7 @@ public abstract class Unit implements Nameable {
* {@code other.convertFromBase(this.convertToBase(value))}.
* Therefore, overriding either of those methods will change the
* output of this method.
- *
+ *
* @param other unit to convert to
* @param value value to convert
* @return converted value
@@ -234,7 +233,7 @@ public abstract class Unit implements Nameable {
* {@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
@@ -269,7 +268,7 @@ public abstract class Unit implements Nameable {
*
* @implSpec This method is used by {@link #convertTo}, and its behaviour
* affects the behaviour of {@code convertTo}.
- *
+ *
* @param value value expressed in <b>this</b> unit
* @return value expressed in <b>base</b> unit
* @since 2018-12-22
@@ -355,9 +354,8 @@ public abstract class Unit implements Nameable {
* @since 2022-03-10
*/
public String toDefinitionString() {
- if (this.unitBase instanceof NamedObjectProduct)
- return "derived from "
- + ((NamedObjectProduct<?>) this.unitBase).getName();
+ if (this.unitBase instanceof Nameable)
+ return "derived from " + ((Nameable) this.unitBase).getName();
else
return "derived from "
+ this.getBase().toString(BaseUnit::getShortName);
diff --git a/src/main/java/sevenUnits/unit/UnitType.java b/src/main/java/sevenUnits/unit/UnitType.java
new file mode 100644
index 0000000..a13051a
--- /dev/null
+++ b/src/main/java/sevenUnits/unit/UnitType.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2022 Adrien Hopkins
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+package sevenUnits.unit;
+
+/**
+ * A type of unit, as chosen by the type of system it is in.
+ * <ul>
+ * <li>{@code METRIC} refers to metric/SI units that pass {@link Unit#isMetric}
+ * <li>{@code SEMI_METRIC} refers to the degree Celsius (which is an official SI
+ * unit but does not pass {@link Unit#isMetric}) and non-metric units intended
+ * for use with the SI.
+ * <li>{@code NON_METRIC} refers to units that are neither metric nor intended
+ * for use with the metric system (e.g. imperial and customary units)
+ * </ul>
+ *
+ * @since 2022-04-10
+ */
+public enum UnitType {
+ METRIC, SEMI_METRIC, NON_METRIC;
+}