Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Commit

Permalink
62: Behavior of equals() for same Quantity value
Browse files Browse the repository at this point in the history
  • Loading branch information
keilw committed Jun 7, 2017
1 parent ccac78b commit 47d2681
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 156 deletions.
21 changes: 14 additions & 7 deletions src/main/java/tec/units/ri/AbstractUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
*
* @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
* @author <a href="mailto:units@catmedia.us">Werner Keil</a>
* @version 1.0.3, March 17, 2017
* @version 1.0.4, June 7, 2017
* @since 1.0
*/
public abstract class AbstractUnit<Q extends Quantity<Q>> implements Unit<Q>, Comparable<Unit<Q>> {
Expand Down Expand Up @@ -333,12 +333,19 @@ public final Unit<Q> alternate(String symbol) {
}

@Override
public final AbstractUnit<Q> transform(UnitConverter operation) {
AbstractUnit<Q> systemUnit = this.getSystemUnit();
UnitConverter cvtr = this.getSystemConverter().concatenate(operation);
if (cvtr.equals(AbstractConverter.IDENTITY))
public final Unit<Q> transform(UnitConverter operation) {
Unit<Q> systemUnit = this.getSystemUnit();
UnitConverter cvtr;
if (this.isSystemUnit()) {
cvtr = this.getSystemConverter().concatenate(operation);
} else {
cvtr = operation;
}
if (cvtr.equals(AbstractConverter.IDENTITY)) {
return systemUnit;
return new TransformedUnit<Q>(systemUnit, cvtr);
} else {
return new TransformedUnit<>(null, this, systemUnit, cvtr);
}
}

@Override
Expand Down Expand Up @@ -417,7 +424,7 @@ public final Unit<?> inverse() {
* the divisor value.
* @return this unit divided by the specified divisor.
*/
public final AbstractUnit<Q> divide(double divisor) {
public final Unit<Q> divide(double divisor) {
if (divisor == 1)
return this;
if (isLongValue(divisor))
Expand Down
Loading

0 comments on commit 47d2681

Please sign in to comment.