From 26291e672b0e683edc9d57710a9a9d96ca199c45 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Sun, 24 Mar 2024 13:14:11 -0500 Subject: Format source code & set explicit UTF-8 --- src/main/java/sevenUnits/unit/Unitlike.java | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/main/java/sevenUnits/unit/Unitlike.java') diff --git a/src/main/java/sevenUnits/unit/Unitlike.java b/src/main/java/sevenUnits/unit/Unitlike.java index 68de2c2..fef424e 100644 --- a/src/main/java/sevenUnits/unit/Unitlike.java +++ b/src/main/java/sevenUnits/unit/Unitlike.java @@ -55,7 +55,7 @@ public abstract class Unitlike implements Nameable { return new FunctionalUnitlike<>(base, NameSymbol.EMPTY, converterFrom, converterTo); } - + /** * Returns a unitlike form from its base and the functions it uses to convert * to and from its base. @@ -78,28 +78,28 @@ public abstract class Unitlike implements Nameable { final ToDoubleFunction converterTo, final NameSymbol ns) { return new FunctionalUnitlike<>(base, ns, converterFrom, converterTo); } - + /** * The combination of units that this unit is based on. * * @since 2019-10-16 */ private final ObjectProduct unitBase; - + /** * This unit's name(s) and symbol * * @since 2020-09-07 */ private final NameSymbol nameSymbol; - + /** * Cache storing the result of getDimension() * * @since 2019-10-16 */ private transient ObjectProduct dimension = null; - + /** * @param unitBase * @since 2020-09-07 @@ -109,7 +109,7 @@ public abstract class Unitlike implements Nameable { "unitBase may not be null"); this.nameSymbol = Objects.requireNonNull(ns, "ns may not be null"); } - + /** * Checks if a value expressed in this unitlike form can be converted to a * value expressed in {@code other} @@ -124,7 +124,7 @@ public abstract class Unitlike implements Nameable { Objects.requireNonNull(other, "other must not be null."); return Objects.equals(this.getBase(), other.getBase()); } - + /** * Checks if a value expressed in this unitlike form can be converted to a * value expressed in {@code other} @@ -139,9 +139,9 @@ public abstract class Unitlike implements Nameable { Objects.requireNonNull(other, "other must not be null."); return Objects.equals(this.getBase(), other.getBase()); } - + protected abstract V convertFromBase(double value); - + /** * Converts a value expressed in this unitlike form to a value expressed in * {@code other}. @@ -150,7 +150,7 @@ public abstract class Unitlike 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 @@ -168,7 +168,7 @@ public abstract class Unitlike implements Nameable { throw new IllegalArgumentException( String.format("Cannot convert from %s to %s.", this, other)); } - + /** * Converts a value expressed in this unitlike form to a value expressed in * {@code other}. @@ -196,9 +196,9 @@ public abstract class Unitlike implements Nameable { throw new IllegalArgumentException( String.format("Cannot convert from %s to %s.", this, other)); } - + protected abstract double convertToBase(V value); - + /** * @return combination of units that this unit is based on * @since 2018-12-22 @@ -207,7 +207,7 @@ public abstract class Unitlike implements Nameable { public final ObjectProduct getBase() { return this.unitBase; } - + /** * @return dimension measured by this unit * @since 2018-12-22 @@ -217,16 +217,16 @@ public abstract class Unitlike implements Nameable { if (this.dimension == null) { final Map mapping = this.unitBase.exponentMap(); final Map dimensionMap = new HashMap<>(); - + for (final BaseUnit key : mapping.keySet()) { dimensionMap.put(key.getBaseDimension(), mapping.get(key)); } - + this.dimension = ObjectProduct.fromExponentMapping(dimensionMap); } return this.dimension; } - + /** * @return the nameSymbol * @since 2020-09-07 @@ -235,7 +235,7 @@ public abstract class Unitlike implements Nameable { public final NameSymbol getNameSymbol() { return this.nameSymbol; } - + @Override public String toString() { return this.getPrimaryName().orElse("Unnamed unitlike form") @@ -247,7 +247,7 @@ public abstract class Unitlike implements Nameable { + (this.getOtherNames().isEmpty() ? "" : ", also called " + String.join(", ", this.getOtherNames())); } - + /** * @param ns name(s) and symbol to use * @return a copy of this unitlike form with provided name(s) and symbol -- cgit v1.2.3