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/BaseUnit.java2
-rw-r--r--src/main/java/sevenUnits/unit/Unit.java38
2 files changed, 18 insertions, 22 deletions
diff --git a/src/main/java/sevenUnits/unit/BaseUnit.java b/src/main/java/sevenUnits/unit/BaseUnit.java
index b1e30fb..ee2c277 100644
--- a/src/main/java/sevenUnits/unit/BaseUnit.java
+++ b/src/main/java/sevenUnits/unit/BaseUnit.java
@@ -75,7 +75,7 @@ public final class BaseUnit extends Unit {
*/
private BaseUnit(final BaseDimension dimension, final String primaryName,
final String symbol, final Set<String> otherNames) {
- super(primaryName, symbol, otherNames);
+ super(NameSymbol.of(primaryName, symbol, otherNames));
this.dimension = Objects.requireNonNull(dimension,
"dimension must not be null.");
}
diff --git a/src/main/java/sevenUnits/unit/Unit.java b/src/main/java/sevenUnits/unit/Unit.java
index 58b4e10..005b6f7 100644
--- a/src/main/java/sevenUnits/unit/Unit.java
+++ b/src/main/java/sevenUnits/unit/Unit.java
@@ -17,10 +17,8 @@
package sevenUnits.unit;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
-import java.util.Set;
import java.util.function.DoubleUnaryOperator;
import sevenUnits.utils.DecimalComparison;
@@ -110,6 +108,19 @@ public abstract class Unit implements Nameable {
private transient ObjectProduct<BaseDimension> dimension = null;
/**
+ * A constructor that constructs {@code BaseUnit} instances.
+ *
+ * @since 2019-10-16
+ */
+ Unit(final NameSymbol nameSymbol) {
+ if (this instanceof BaseUnit) {
+ this.unitBase = ObjectProduct.oneOf((BaseUnit) this);
+ } else
+ throw new AssertionError();
+ this.nameSymbol = nameSymbol;
+ }
+
+ /**
* Creates the {@code Unit}.
*
* @param unitBase base of unit
@@ -124,21 +135,6 @@ public abstract class Unit implements Nameable {
}
/**
- * A constructor that constructs {@code BaseUnit} instances.
- *
- * @since 2019-10-16
- */
- Unit(final String primaryName, final String symbol,
- final Set<String> otherNames) {
- if (this instanceof BaseUnit) {
- this.unitBase = ObjectProduct.oneOf((BaseUnit) this);
- } else
- throw new AssertionError();
- this.nameSymbol = NameSymbol.of(primaryName, symbol,
- new HashSet<>(otherNames));
- }
-
- /**
* @return this unit as a {@link Unitlike}
* @since 2020-09-07
*/
@@ -192,7 +188,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
@@ -208,7 +204,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
@@ -235,7 +231,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
@@ -270,7 +266,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