diff options
author | Adrien Hopkins <masterofnumbers17@gmail.com> | 2019-11-26 15:20:04 -0500 |
---|---|---|
committer | Adrien Hopkins <masterofnumbers17@gmail.com> | 2019-11-26 15:20:04 -0500 |
commit | a966676c629f7f14fcbba82a9ada5e2cbeca8314 (patch) | |
tree | 63e93526528f963d99570230a4b72830400840bc /src/org/unitConverter/unit/LinearUnit.java | |
parent | 7bf4824a0619a79cb10faf8f83146b96e51341d2 (diff) |
Updated the documentation of existing classes.
Diffstat (limited to 'src/org/unitConverter/unit/LinearUnit.java')
-rw-r--r-- | src/org/unitConverter/unit/LinearUnit.java | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/org/unitConverter/unit/LinearUnit.java b/src/org/unitConverter/unit/LinearUnit.java index 7b7338b..1532fc4 100644 --- a/src/org/unitConverter/unit/LinearUnit.java +++ b/src/org/unitConverter/unit/LinearUnit.java @@ -128,11 +128,21 @@ public final class LinearUnit extends Unit { this.conversionFactor = conversionFactor; } + /** + * {@inheritDoc} + * + * Converts by dividing by {@code conversionFactor} + */ @Override protected double convertFromBase(final double value) { return value / this.getConversionFactor(); } + /** + * {@inheritDoc} + * + * Converts by multiplying by {@code conversionFactor} + */ @Override protected double convertToBase(final double value) { return value * this.getConversionFactor(); @@ -170,6 +180,11 @@ public final class LinearUnit extends Unit { return valueOf(base, this.getConversionFactor() / divisor.getConversionFactor()); } + /** + * {@inheritDoc} + * + * Uses the base and conversion factor of units to test for equality. + */ @Override public boolean equals(final Object obj) { if (!(obj instanceof LinearUnit)) @@ -187,6 +202,11 @@ public final class LinearUnit extends Unit { return this.conversionFactor; } + /** + * {@inheritDoc} + * + * Uses the base and conversion factor to compute a hash code. + */ @Override public int hashCode() { return 31 * this.getBase().hashCode() + DecimalComparison.hash(this.getConversionFactor()); @@ -234,7 +254,7 @@ public final class LinearUnit extends Unit { throw new IllegalArgumentException( String.format("Incompatible units for subtraction \"%s\" and \"%s\".", this, subtrahendend)); - // add the units + // subtract the units return valueOf(this.getBase(), this.getConversionFactor() - subtrahendend.getConversionFactor()); } @@ -312,7 +332,10 @@ public final class LinearUnit extends Unit { return valueOf(this.getBase().toExponent(exponent), Math.pow(this.conversionFactor, exponent)); } - // returns a definition of the unit + /** + * @return a string providing a definition of this unit + * @since 2019-10-21 + */ @Override public String toString() { return this.getPrimaryName().orElse("Unnamed unit") |