From a966676c629f7f14fcbba82a9ada5e2cbeca8314 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Tue, 26 Nov 2019 15:20:04 -0500 Subject: Updated the documentation of existing classes. --- src/org/unitConverter/unit/LinearUnit.java | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/org/unitConverter/unit/LinearUnit.java') 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") -- cgit v1.2.3