summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Hopkins <adrien.p.hopkins@gmail.com>2025-06-04 18:39:03 -0500
committerAdrien Hopkins <adrien.p.hopkins@gmail.com>2025-06-04 18:39:03 -0500
commit25f972d198e50ad5a54fa175ec39887f02c33fdc (patch)
tree2807b0ee27a5594f0dfcab421e6840c1270a8e6c
parentae0559a9432f85f9147eeb80b35f1b2947889acd (diff)
Remove most comment warnings
In some cases I've used @SuppressWarnings, which Gradle doesn't seem to respect, but I've solved all the other ones.
-rw-r--r--src/main/java/sevenUnits/unit/BaseUnit.java7
-rw-r--r--src/main/java/sevenUnits/unit/BritishImperial.java8
-rw-r--r--src/main/java/sevenUnits/unit/FunctionalUnit.java1
-rw-r--r--src/main/java/sevenUnits/unit/LinearUnit.java6
-rw-r--r--src/main/java/sevenUnits/unit/LinearUnitValue.java94
-rw-r--r--src/main/java/sevenUnits/unit/LoadingException.java59
-rw-r--r--src/main/java/sevenUnits/unit/Metric.java3
-rw-r--r--src/main/java/sevenUnits/unit/USCustomary.java3
-rw-r--r--src/main/java/sevenUnits/unit/Unit.java4
-rw-r--r--src/main/java/sevenUnits/unit/UnitDatabase.java16
-rw-r--r--src/main/java/sevenUnits/unit/UnitPrefix.java5
-rw-r--r--src/main/java/sevenUnits/unit/UnitType.java7
-rw-r--r--src/main/java/sevenUnits/unit/UnitValue.java11
-rw-r--r--src/main/java/sevenUnits/utils/NameSymbol.java4
-rw-r--r--src/main/java/sevenUnits/utils/ObjectProduct.java6
-rw-r--r--src/main/java/sevenUnits/utils/UncertainDouble.java144
-rw-r--r--src/main/java/sevenUnitsGUI/DefaultPrefixRepetitionRule.java2
-rw-r--r--src/main/java/sevenUnitsGUI/GridBagBuilder.java7
-rw-r--r--src/main/java/sevenUnitsGUI/Presenter.java2
-rw-r--r--src/main/java/sevenUnitsGUI/StandardDisplayRules.java2
-rw-r--r--src/main/java/sevenUnitsGUI/ViewBot.java30
21 files changed, 307 insertions, 114 deletions
diff --git a/src/main/java/sevenUnits/unit/BaseUnit.java b/src/main/java/sevenUnits/unit/BaseUnit.java
index fe85a7b..4781be9 100644
--- a/src/main/java/sevenUnits/unit/BaseUnit.java
+++ b/src/main/java/sevenUnits/unit/BaseUnit.java
@@ -50,9 +50,10 @@ public final class BaseUnit extends Unit {
/**
* Gets a base unit from the dimension it measures, its name and its symbol.
*
- * @param dimension dimension measured by this unit
- * @param name name of unit
- * @param symbol symbol of unit
+ * @param dimension dimension measured by this unit
+ * @param name name of unit
+ * @param symbol symbol of unit
+ * @param otherNames other possible names of unit
* @return base unit
* @since 2019-10-21
*/
diff --git a/src/main/java/sevenUnits/unit/BritishImperial.java b/src/main/java/sevenUnits/unit/BritishImperial.java
index 69a3c05..16255da 100644
--- a/src/main/java/sevenUnits/unit/BritishImperial.java
+++ b/src/main/java/sevenUnits/unit/BritishImperial.java
@@ -24,6 +24,9 @@ import sevenUnits.utils.NameSymbol;
* @author Adrien Hopkins
* @since 2019-10-21
*/
+// this class is just constants, most of which are obvious from the variable name
+// so no need to check for missing values
+@SuppressWarnings("javadoc")
public final class BritishImperial {
/**
* Imperial units that measure area
@@ -55,11 +58,16 @@ public final class BritishImperial {
public static final LinearUnit FOOT = YARD.dividedBy(3);
public static final LinearUnit INCH = FOOT.dividedBy(12);
public static final LinearUnit THOU = INCH.dividedBy(1000);
+ /** A chain, equal to 22 yards. */
public static final LinearUnit CHAIN = YARD.times(22);
+ /** A furlong, equal to 10 chains or 220 yards. */
public static final LinearUnit FURLONG = CHAIN.times(10);
+ /** A mile, equal to 8 furlongs or 1760 yards. */
public static final LinearUnit MILE = FURLONG.times(8);
+ /** A league, equal to 3 miles. */
public static final LinearUnit LEAGUE = MILE.times(3);
+ /** A nautical mile, around 1 arcminute around the Earth's circumference. */
public static final LinearUnit NAUTICAL_MILE = Metric.METRE.times(1852);
public static final LinearUnit CABLE = NAUTICAL_MILE.dividedBy(10);
public static final LinearUnit FATHOM = CABLE.dividedBy(100);
diff --git a/src/main/java/sevenUnits/unit/FunctionalUnit.java b/src/main/java/sevenUnits/unit/FunctionalUnit.java
index 6de446f..8ca87b3 100644
--- a/src/main/java/sevenUnits/unit/FunctionalUnit.java
+++ b/src/main/java/sevenUnits/unit/FunctionalUnit.java
@@ -74,6 +74,7 @@ final class FunctionalUnit extends Unit {
* base and returns that value expressed in this unit.
* @param converterTo function that accepts a value expressed in the unit
* and returns that value expressed in the unit's base.
+ * @param ns name and symbol of resulting unit
* @throws NullPointerException if any argument is null
* @since 2019-05-22
*/
diff --git a/src/main/java/sevenUnits/unit/LinearUnit.java b/src/main/java/sevenUnits/unit/LinearUnit.java
index d453a43..99bea96 100644
--- a/src/main/java/sevenUnits/unit/LinearUnit.java
+++ b/src/main/java/sevenUnits/unit/LinearUnit.java
@@ -66,6 +66,7 @@ public final class LinearUnit extends Unit {
}
/**
+ * @param unit unit to get base version of
* @return the base unit associated with {@code unit}, as a
* {@code LinearUnit}.
* @since 2020-10-02
@@ -232,6 +233,7 @@ public final class LinearUnit extends Unit {
}
/**
+ * @param other unit to test equality with
* @return true iff this unit and other are equal,
* ignoring small differences caused by floating-point error.
*
@@ -397,7 +399,9 @@ public final class LinearUnit extends Unit {
/**
* Returns this unit to an exponent, rounding the resulting dimensions to the
* nearest integer.
- *
+ *
+ * @param exponent exponent to raise unit to
+ * @return result of rounded exponentation
* @since 2024-08-22
* @see ObjectProduct#toExponentRounded
*/
diff --git a/src/main/java/sevenUnits/unit/LinearUnitValue.java b/src/main/java/sevenUnits/unit/LinearUnitValue.java
index 678c59c..e4cc820 100644
--- a/src/main/java/sevenUnits/unit/LinearUnitValue.java
+++ b/src/main/java/sevenUnits/unit/LinearUnitValue.java
@@ -36,8 +36,9 @@ import sevenUnits.utils.UncertainDouble;
* @since 2020-07-26
*/
public final class LinearUnitValue {
+ /** The value 1 as a LinearUnitValue. */
public static final LinearUnitValue ONE = getExact(Metric.ONE, 1);
-
+
/**
* Gets an exact {@code LinearUnitValue}
*
@@ -52,12 +53,12 @@ public final class LinearUnitValue {
Objects.requireNonNull(unit, "unit must not be null"),
UncertainDouble.of(value, 0));
}
-
+
/**
* Gets an uncertain {@code LinearUnitValue}
*
- * @param unit unit to express with
- * @param value value to express
+ * @param unit unit to express with
+ * @param value value to express
* @return uncertain {@code LinearUnitValue} instance
* @since 2020-07-26
*/
@@ -67,11 +68,11 @@ public final class LinearUnitValue {
Objects.requireNonNull(unit, "unit must not be null"),
Objects.requireNonNull(value, "value may not be null"));
}
-
+
private final LinearUnit unit;
-
+
private final UncertainDouble value;
-
+
/**
* @param unit unit to express as
* @param value value to express
@@ -81,7 +82,7 @@ public final class LinearUnitValue {
this.unit = unit;
this.value = value;
}
-
+
/**
* @return this value as a {@code UnitValue}. All uncertainty information is
* removed from the returned value.
@@ -90,7 +91,7 @@ public final class LinearUnitValue {
public final UnitValue asUnitValue() {
return UnitValue.of(this.unit, this.value.value());
}
-
+
/**
* @param other a {@code LinearUnit}
* @return true iff this value can be represented with {@code other}.
@@ -99,7 +100,7 @@ public final class LinearUnitValue {
public final boolean canConvertTo(final LinearUnit other) {
return this.unit.canConvertTo(other);
}
-
+
/**
* Returns a LinearUnitValue that represents the same value expressed in a
* different unit
@@ -111,12 +112,13 @@ public final class LinearUnitValue {
public final LinearUnitValue convertTo(final LinearUnit other) {
return LinearUnitValue.of(other, this.unit.convertTo(other, this.value));
}
-
+
/**
* Convert a LinearUnitValue to a sum of multiple units, where all but the
* last have exact integer values.
*
* @param others units to convert to
+ * @return terms of the sum
* @throws IllegalArgumentException if no units are provided or units
* provided have incompatible bases
* @since 2024-08-15
@@ -130,7 +132,7 @@ public final class LinearUnitValue {
throw new IllegalArgumentException(
"All provided units must have the same base as the value.");
}
-
+
LinearUnitValue remaining = this;
final List<LinearUnitValue> values = new ArrayList<>(others.size());
for (final LinearUnit unit : others.subList(0, others.size() - 1)) {
@@ -140,13 +142,13 @@ public final class LinearUnitValue {
values.add(value);
remaining = remaining.minus(value);
}
-
+
final LinearUnitValue lastValue = remaining
.convertTo(others.get(others.size() - 1));
values.add(lastValue);
return values;
}
-
+
/**
* Divides this value by a scalar
*
@@ -157,7 +159,7 @@ public final class LinearUnitValue {
public LinearUnitValue dividedBy(final double divisor) {
return LinearUnitValue.of(this.unit, this.value.dividedByExact(divisor));
}
-
+
/**
* Divides this value by another value
*
@@ -169,7 +171,7 @@ public final class LinearUnitValue {
return LinearUnitValue.of(this.unit.dividedBy(divisor.unit),
this.value.dividedBy(divisor.value));
}
-
+
/**
* Returns true if this and obj represent the same value, regardless of
* whether or not they are expressed in the same unit. So (1000 m).equals(1
@@ -187,14 +189,17 @@ public final class LinearUnitValue {
&& this.unit.convertToBase(this.value)
.equals(other.unit.convertToBase(other.value));
}
-
+
/**
* Returns true if this and obj represent the same value, regardless of
* whether or not they are expressed in the same unit. So (1000 m).equals(1
* km) returns true.
- * <p>
- * If avoidFPErrors is true, this method will attempt to avoid floating-point
- * errors, at the cost of not always being transitive.
+ *
+ * @param obj object to test equality with
+ * @param avoidFPErrors if true, this method will attempt to avoid
+ * floating-point errors, at the cost of not always
+ * being transitive.
+ * @return true iff this and obj are equal
*
* @since 2020-07-28
*/
@@ -208,7 +213,7 @@ public final class LinearUnitValue {
&& DecimalComparison.equals(this.unit.convertToBase(this.value),
other.unit.convertToBase(other.value));
}
-
+
/**
* @param other another {@code LinearUnitValue}
* @return true iff this and other are within each other's uncertainty range
@@ -222,10 +227,10 @@ public final class LinearUnitValue {
final LinearUnit base = LinearUnit.valueOf(this.unit.getBase(), 1);
final LinearUnitValue thisBase = this.convertTo(base);
final LinearUnitValue otherBase = other.convertTo(base);
-
+
return thisBase.value.equivalent(otherBase.value);
}
-
+
/**
* @return the unit
* @since 2020-09-29
@@ -233,7 +238,7 @@ public final class LinearUnitValue {
public final LinearUnit getUnit() {
return this.unit;
}
-
+
/**
* @return the value
* @since 2020-09-29
@@ -241,7 +246,7 @@ public final class LinearUnitValue {
public final UncertainDouble getValue() {
return this.value;
}
-
+
/**
* @return the exact value
* @since 2020-09-07
@@ -249,13 +254,13 @@ public final class LinearUnitValue {
public final double getValueExact() {
return this.value.value();
}
-
+
@Override
public int hashCode() {
return Objects.hash(this.unit.getBase(),
this.unit.convertToBase(this.getValue()));
}
-
+
/**
* Returns the difference of this value and another, expressed in this
* value's unit
@@ -268,17 +273,17 @@ public final class LinearUnitValue {
*/
public LinearUnitValue minus(final LinearUnitValue subtrahend) {
Objects.requireNonNull(subtrahend, "subtrahend may not be null");
-
+
if (!this.canConvertTo(subtrahend.unit))
throw new IllegalArgumentException(String.format(
"Incompatible units for subtraction \"%s\" and \"%s\".",
this.unit, subtrahend.unit));
-
+
final LinearUnitValue otherConverted = subtrahend.convertTo(this.unit);
return LinearUnitValue.of(this.unit,
this.value.minus(otherConverted.value));
}
-
+
/**
* Returns the sum of this value and another, expressed in this value's unit
*
@@ -290,17 +295,17 @@ public final class LinearUnitValue {
*/
public LinearUnitValue plus(final LinearUnitValue addend) {
Objects.requireNonNull(addend, "addend may not be null");
-
+
if (!this.canConvertTo(addend.unit))
throw new IllegalArgumentException(String.format(
"Incompatible units for addition \"%s\" and \"%s\".", this.unit,
addend.unit));
-
+
final LinearUnitValue otherConverted = addend.convertTo(this.unit);
return LinearUnitValue.of(this.unit,
this.value.plus(otherConverted.value));
}
-
+
/**
* Multiplies this value by a scalar
*
@@ -311,7 +316,7 @@ public final class LinearUnitValue {
public LinearUnitValue times(final double multiplier) {
return LinearUnitValue.of(this.unit, this.value.timesExact(multiplier));
}
-
+
/**
* Multiplies this value by another value
*
@@ -323,7 +328,7 @@ public final class LinearUnitValue {
return LinearUnitValue.of(this.unit.times(multiplier.unit),
this.value.times(multiplier.value));
}
-
+
/**
* Raises a value to an exponent
*
@@ -335,9 +340,12 @@ public final class LinearUnitValue {
return LinearUnitValue.of(this.unit.toExponent(exponent),
this.value.toExponentExact(exponent));
}
-
+
/**
* Raises this value to an exponent, rounding all dimensions to integers.
+ *
+ * @param exponent exponent to raise this value to
+ * @return result of exponentation
*
* @since 2024-08-22
* @see ObjectProduct#toExponentRounded
@@ -346,12 +354,12 @@ public final class LinearUnitValue {
return LinearUnitValue.of(this.unit.toExponentRounded(exponent),
this.value.toExponentExact(exponent));
}
-
+
@Override
public String toString() {
return this.toString(!this.value.isExact(), RoundingMode.HALF_EVEN);
}
-
+
/**
* Returns a string representing the object. <br>
* If the attached unit has a name or symbol, the string looks like "12 km".
@@ -362,6 +370,10 @@ public final class LinearUnitValue {
* <p>
* Non-exact values are rounded intelligently based on their uncertainty.
*
+ * @param showUncertainty whether to show the value's uncertainty
+ * @param roundingMode how to round numbers in this string
+ * @return string representing this value
+ *
* @since 2020-07-26
*/
public String toString(final boolean showUncertainty,
@@ -369,9 +381,9 @@ public final class LinearUnitValue {
final Optional<String> primaryName = this.unit.getPrimaryName();
final Optional<String> symbol = this.unit.getSymbol();
final String chosenName = symbol.orElse(primaryName.orElse(null));
-
+
final UncertainDouble baseValue = this.unit.convertToBase(this.value);
-
+
// get rounded strings
// if showUncertainty is true, add brackets around the string
final String valueString = (showUncertainty ? "(" : "")
@@ -380,7 +392,7 @@ public final class LinearUnitValue {
final String baseValueString = (showUncertainty ? "(" : "")
+ baseValue.toString(showUncertainty, roundingMode)
+ (showUncertainty ? ")" : "");
-
+
// create string
if (chosenName == null)
return String.format("%s unnamed unit (= %s %s)", valueString,
diff --git a/src/main/java/sevenUnits/unit/LoadingException.java b/src/main/java/sevenUnits/unit/LoadingException.java
index 9376ed7..18630a4 100644
--- a/src/main/java/sevenUnits/unit/LoadingException.java
+++ b/src/main/java/sevenUnits/unit/LoadingException.java
@@ -27,20 +27,29 @@ import java.util.Optional;
* @since 2024-08-22
*/
public final class LoadingException extends RuntimeException {
+ /** The type of file that was being loaded. */
public static enum FileType {
- UNIT, DIMENSION
+ @SuppressWarnings("javadoc") UNIT, @SuppressWarnings("javadoc") DIMENSION
}
-
+
private static final long serialVersionUID = -8167971828216907607L;
-
+
private final long lineNumber;
private final String line;
private final Optional<Path> file;
-
+
private final FileType fileType;
-
+
private final RuntimeException problem;
-
+
+ /**
+ * Create a LoadingException from some information, without a file.
+ *
+ * @param lineNumber line number error happened on
+ * @param line text of invalid line
+ * @param fileType type of file
+ * @param problem problem, as an Exception
+ */
public LoadingException(long lineNumber, String line, FileType fileType,
RuntimeException problem) {
super(problem);
@@ -50,7 +59,16 @@ public final class LoadingException extends RuntimeException {
this.fileType = fileType;
this.problem = problem;
}
-
+
+ /**
+ * Create a LoadingException from some information, with a file.
+ *
+ * @param lineNumber line number error happened on
+ * @param line text of invalid line
+ * @param file file error happened on
+ * @param fileType type of file
+ * @param problem problem, as an Exception
+ */
public LoadingException(long lineNumber, String line, Path file,
FileType fileType, RuntimeException problem) {
super(problem);
@@ -60,15 +78,21 @@ public final class LoadingException extends RuntimeException {
this.fileType = fileType;
this.problem = problem;
}
-
+
+ /**
+ * @return the file this error happened in, if there is one
+ */
public Optional<Path> file() {
return this.file;
}
-
+
+ /**
+ * @return type of file that this error happened in
+ */
public FileType fileType() {
return this.fileType;
}
-
+
@Override
public String getMessage() {
return this.file
@@ -81,15 +105,24 @@ public final class LoadingException extends RuntimeException {
this.lineNumber, this.fileType.toString().toLowerCase(),
this.line, this.problem));
}
-
+
+ /**
+ * @return text of line that caused this error
+ */
public String line() {
return this.line;
}
-
+
+ /**
+ * @return number of line that caused this error
+ */
public long lineNumber() {
return this.lineNumber;
}
-
+
+ /**
+ * @return the error, as an exception
+ */
public RuntimeException problem() {
return this.problem;
}
diff --git a/src/main/java/sevenUnits/unit/Metric.java b/src/main/java/sevenUnits/unit/Metric.java
index 2fc3928..16859bf 100644
--- a/src/main/java/sevenUnits/unit/Metric.java
+++ b/src/main/java/sevenUnits/unit/Metric.java
@@ -37,6 +37,9 @@ import sevenUnits.utils.ObjectProduct;
* @author Adrien Hopkins
* @since 2019-10-16
*/
+// this class is just constants, most of which are obvious from the variable name
+// so no need to check for missing values
+@SuppressWarnings("javadoc")
public final class Metric {
/// dimensions used by SI units
// base dimensions, as BaseDimensions
diff --git a/src/main/java/sevenUnits/unit/USCustomary.java b/src/main/java/sevenUnits/unit/USCustomary.java
index fce829e..fa3f26e 100644
--- a/src/main/java/sevenUnits/unit/USCustomary.java
+++ b/src/main/java/sevenUnits/unit/USCustomary.java
@@ -22,6 +22,9 @@ package sevenUnits.unit;
* @author Adrien Hopkins
* @since 2019-10-21
*/
+// this class is just constants, most of which are obvious from the variable name
+// so no need to check for missing values
+@SuppressWarnings("javadoc")
public final class USCustomary {
/**
* US Customary units that measure area
diff --git a/src/main/java/sevenUnits/unit/Unit.java b/src/main/java/sevenUnits/unit/Unit.java
index d25b362..61a5dbf 100644
--- a/src/main/java/sevenUnits/unit/Unit.java
+++ b/src/main/java/sevenUnits/unit/Unit.java
@@ -262,7 +262,7 @@ public abstract class Unit implements Nameable {
}
/**
- * Returns true iff this unit is metric.
+ * Determines whether this unit is metric.
* <p>
* "Metric" is defined by three conditions:
* <ul>
@@ -278,6 +278,8 @@ public abstract class Unit implements Nameable {
* All SI units (as designated by the BIPM) except the degree Celsius are
* considered "metric" by this definition.
*
+ * @return true iff this unit is metric.
+ *
* @since 2020-08-27
*/
public final boolean isMetric() {
diff --git a/src/main/java/sevenUnits/unit/UnitDatabase.java b/src/main/java/sevenUnits/unit/UnitDatabase.java
index 444b366..95e953f 100644
--- a/src/main/java/sevenUnits/unit/UnitDatabase.java
+++ b/src/main/java/sevenUnits/unit/UnitDatabase.java
@@ -212,6 +212,8 @@ public final class UnitDatabase {
* Creates the
* {@code UnitsDatabase.PrefixedUnitMap.PrefixedUnitNameSet.PrefixedUnitNameIterator}.
*
+ * @param map map to base iterator on
+ *
* @since 2019-04-14
* @since v0.2.0
*/
@@ -527,6 +529,8 @@ public final class UnitDatabase {
* Creates the
* {@code UnitsDatabase.PrefixedUnitMap.PrefixedUnitNameSet.PrefixedUnitNameIterator}.
*
+ * @param map map to base itorator on
+ *
* @since 2019-04-14
* @since v0.2.0
*/
@@ -1529,6 +1533,9 @@ public final class UnitDatabase {
/**
* Returns true iff there is a unit set with this name.
+ *
+ * @param name name to check for
+ * @return true iff there is a unit set with this name
*
* @since 2024-08-16
*/
@@ -1574,7 +1581,7 @@ public final class UnitDatabase {
// the previous operation breaks negative numbers, fix them!
// (i.e. -2 becomes - 2)
- // FIXME the previous operaton also breaks stuff like "1e-5"
+ // FIXME the previous operation also breaks stuff like "1e-5"
for (int i = 0; i < modifiedExpression.length(); i++) {
if (modifiedExpression.charAt(i) == '-'
&& (i < 2 || Arrays.asList('+', '-', '*', '/', '|', '^')
@@ -1620,6 +1627,7 @@ public final class UnitDatabase {
* </ul>
*
* @param expression expression to parse
+ * @return parsed unit dimension
* @throws IllegalArgumentException if the expression cannot be parsed
* @throws NullPointerException if expression is null
* @since 2019-04-13
@@ -1848,6 +1856,7 @@ public final class UnitDatabase {
* This method only works with linear units.
*
* @param expression expression to parse
+ * @return parsed unit
* @throws IllegalArgumentException if the expression cannot be parsed
* @throws NullPointerException if expression is null
* @since 2019-01-07
@@ -1890,6 +1899,9 @@ public final class UnitDatabase {
/**
* Get a unit set from its name, throwing a {@link NoSuchElementException} if
* there is none.
+ *
+ * @param name name of unit set
+ * @return unit set with that name
*
* @since 2024-08-16
*/
@@ -1977,6 +1989,7 @@ public final class UnitDatabase {
* {@link #loadDimensionFile}.
*
* @param stream stream to load from
+ * @return list of all errors that happened loading the stream
* @since 2021-03-27
*/
public List<LoadingException> loadDimensionsFromStream(
@@ -2047,6 +2060,7 @@ public final class UnitDatabase {
* {@link #loadUnitsFile}.
*
* @param stream stream to load from
+ * @return list of all errors that happened loading the stream
* @since 2021-03-27
*/
public List<LoadingException> loadUnitsFromStream(InputStream stream) {
diff --git a/src/main/java/sevenUnits/unit/UnitPrefix.java b/src/main/java/sevenUnits/unit/UnitPrefix.java
index ec4be48..be4d8fb 100644
--- a/src/main/java/sevenUnits/unit/UnitPrefix.java
+++ b/src/main/java/sevenUnits/unit/UnitPrefix.java
@@ -124,6 +124,7 @@ public final class UnitPrefix implements Nameable {
}
/**
+ * @param other prefix to compare to
* @return true iff this prefix and other are equal,
* ignoring small differences caused by floating-point error.
*
@@ -175,6 +176,8 @@ public final class UnitPrefix implements Nameable {
/**
* Adds {@code other} to this prefix and returns the result.
+ * @param other prefix to add
+ * @return sum of prefixes
*
* @since 2024-03-03
*/
@@ -184,6 +187,8 @@ public final class UnitPrefix implements Nameable {
/**
* Subtracts {@code other} from this prefix and returns the result.
+ * @param other prefix to subtract
+ * @return difference of prefixes
*
* @since 2024-03-03
*/
diff --git a/src/main/java/sevenUnits/unit/UnitType.java b/src/main/java/sevenUnits/unit/UnitType.java
index 9a87288..6c0f7a9 100644
--- a/src/main/java/sevenUnits/unit/UnitType.java
+++ b/src/main/java/sevenUnits/unit/UnitType.java
@@ -32,7 +32,12 @@ import java.util.function.Predicate;
* @since 2022-04-10
*/
public enum UnitType {
- METRIC, SEMI_METRIC, NON_METRIC;
+ /** Units that pass {@link Unit#isMetric} */
+ METRIC,
+ /** certain exceptions like the degree Celsius */
+ SEMI_METRIC,
+ /** Non-metric, non-excepted units */
+ NON_METRIC;
/**
* Determines which type a unit is. The type will be:
diff --git a/src/main/java/sevenUnits/unit/UnitValue.java b/src/main/java/sevenUnits/unit/UnitValue.java
index 9b485e3..aee836e 100644
--- a/src/main/java/sevenUnits/unit/UnitValue.java
+++ b/src/main/java/sevenUnits/unit/UnitValue.java
@@ -56,6 +56,7 @@ public final class UnitValue {
}
/**
+ * @param other unit to try to convert to
* @return true if this value can be converted to {@code other}.
* @since 2020-10-01
*/
@@ -76,11 +77,12 @@ public final class UnitValue {
}
/**
- * Returns this unit value represented as a {@code LinearUnitValue} with this
+ * Returns this unit value represented as a {@link LinearUnitValue} with this
* unit's base unit as the base.
*
* @param ns name and symbol for the base unit, use NameSymbol.EMPTY if not
* needed.
+ * @return this unit as a {@link LinearUnitValue}
* @since 2020-09-29
*/
public final LinearUnitValue convertToBase(NameSymbol ns) {
@@ -89,13 +91,14 @@ public final class UnitValue {
}
/**
+ * @param newUnit unit to use for this value
* @return a {@code LinearUnitValue} that is equivalent to this value. It
* will have zero uncertainty.
* @since 2020-09-29
*/
- public final LinearUnitValue convertToLinear(LinearUnit other) {
- return LinearUnitValue.getExact(other,
- this.getUnit().convertTo(other, this.getValue()));
+ public final LinearUnitValue convertToLinear(LinearUnit newUnit) {
+ return LinearUnitValue.getExact(newUnit,
+ this.getUnit().convertTo(newUnit, this.getValue()));
}
/**
diff --git a/src/main/java/sevenUnits/utils/NameSymbol.java b/src/main/java/sevenUnits/utils/NameSymbol.java
index 290dcd6..a91009e 100644
--- a/src/main/java/sevenUnits/utils/NameSymbol.java
+++ b/src/main/java/sevenUnits/utils/NameSymbol.java
@@ -31,6 +31,7 @@ import java.util.Set;
* @since 2019-10-21
*/
public final class NameSymbol {
+ /** The {@code NameSymbol} with all fields empty. */
public static final NameSymbol EMPTY = new NameSymbol(Optional.empty(),
Optional.empty(), new HashSet<>());
@@ -297,6 +298,9 @@ public final class NameSymbol {
* Creates and returns a copy of this {@code NameSymbol} with the provided
* extra name. If this {@code NameSymbol} has a primary name, the provided
* name will become an other name, otherwise it will become the primary name.
+ *
+ * @param name additional name to add
+ * @return copy of this NameSymbol with the additional name
*
* @since v0.4.0
* @since 2022-04-19
diff --git a/src/main/java/sevenUnits/utils/ObjectProduct.java b/src/main/java/sevenUnits/utils/ObjectProduct.java
index d403bdc..3861095 100644
--- a/src/main/java/sevenUnits/utils/ObjectProduct.java
+++ b/src/main/java/sevenUnits/utils/ObjectProduct.java
@@ -31,6 +31,7 @@ import java.util.function.Function;
* objects can be multiplied and exponentiated.
*
* @author Adrien Hopkins
+ * @param <T> type of object that is being multiplied
* @since 2019-10-16
*/
public class ObjectProduct<T> implements Nameable {
@@ -69,6 +70,7 @@ public class ObjectProduct<T> implements Nameable {
* else.
*
* @param object object that will be in the product
+ * @param <T> type of object contained in returned ObjectProduct
* @return product
* @since 2019-10-16
* @throws NullPointerException if object is null
@@ -267,6 +269,9 @@ public class ObjectProduct<T> implements Nameable {
*
* This function will send a warning (via standard error) if the rounding
* significantly changes the value.
+ *
+ * @param exponent exponent to raise this product to
+ * @return result of exponentiation
*
* @since 2024-08-22
*/
@@ -338,6 +343,7 @@ public class ObjectProduct<T> implements Nameable {
}
/**
+ * @param nameSymbol name to add to this product
* @return named version of this {@code ObjectProduct}, using data from
* {@code nameSymbol}
* @since 2021-12-15
diff --git a/src/main/java/sevenUnits/utils/UncertainDouble.java b/src/main/java/sevenUnits/utils/UncertainDouble.java
index ca94817..c70574a 100644
--- a/src/main/java/sevenUnits/utils/UncertainDouble.java
+++ b/src/main/java/sevenUnits/utils/UncertainDouble.java
@@ -35,21 +35,24 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
* The exact value 0
*/
public static final UncertainDouble ZERO = UncertainDouble.of(0, 0);
-
+
static final String NUMBER_REGEX = "(\\d+(?:[\\.,]\\d+))";
-
+
/**
* A regular expression that can recognize toString forms
*/
static final Pattern TO_STRING = Pattern.compile(NUMBER_REGEX
// optional "± [number]"
+ "(?:\\s*(?:±|\\+-)\\s*" + NUMBER_REGEX + ")?");
-
+
/**
* Gets an UncertainDouble from a double string. The uncertainty of the
* double will be one of the lowest decimal place of the number. For example,
* "12345.678" will become 12345.678 ± 0.001.
*
+ * @param s string to parse
+ * @return parsed {@code UncertainDouble}
+ *
* @throws NumberFormatException if the argument is not a number
*
* @since 2022-04-18
@@ -59,10 +62,11 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
final double uncertainty = Math.pow(10, -value.scale());
return UncertainDouble.of(value.doubleValue(), uncertainty);
}
-
+
/**
- * Parses a string in the form of {@link UncertainDouble#toString(boolean, RoundingMode)}
- * and returns the corresponding {@code UncertainDouble} instance.
+ * Parses a string in the form of
+ * {@link UncertainDouble#toString(boolean, RoundingMode)} and returns the
+ * corresponding {@code UncertainDouble} instance.
* <p>
* This method allows some alternative forms of the string representation,
* such as using "+-" instead of "±".
@@ -75,11 +79,11 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
public static final UncertainDouble fromString(String s) {
Objects.requireNonNull(s, "s may not be null");
final Matcher matcher = TO_STRING.matcher(s);
-
+
if (!matcher.matches())
throw new IllegalArgumentException(
"Could not parse string \"" + s + "\".");
-
+
double value, uncertainty;
try {
value = Double.parseDouble(matcher.group(1));
@@ -87,7 +91,7 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
throw new IllegalArgumentException(
"String " + s + " not in correct format.");
}
-
+
final String uncertaintyString = matcher.group(2);
if (uncertaintyString == null) {
uncertainty = 0;
@@ -99,35 +103,45 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
"String " + s + " not in correct format.");
}
}
-
+
return UncertainDouble.of(value, uncertainty);
}
-
+
/**
* Gets an {@code UncertainDouble} from its value and <b>absolute</b>
* uncertainty.
*
+ * @param value double's value
+ * @param uncertainty double's uncertainty (non-negative)
+ * @return {@code UncertainDouble} instance with these parameters
+ *
* @since 2020-09-07
*/
public static final UncertainDouble of(double value, double uncertainty) {
return new UncertainDouble(value, uncertainty);
}
-
+
/**
* Gets an {@code UncertainDouble} from its value and <b>relative</b>
* uncertainty.
*
+ * @param value double's value
+ * @param relativeUncertainty double's uncertainty (non-negative); the
+ * absolute uncertainty is equal to this value
+ * multiplied by {@code relativeUncertainty}
+ * @return {@code UncertainDouble} instance with these parameters
+ *
* @since 2020-09-07
*/
public static final UncertainDouble ofRelative(double value,
double relativeUncertainty) {
return new UncertainDouble(value, value * relativeUncertainty);
}
-
+
private final double value;
-
+
private final double uncertainty;
-
+
/**
* @param value
* @param uncertainty
@@ -138,7 +152,7 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
// uncertainty should only ever be positive
this.uncertainty = Math.abs(uncertainty);
}
-
+
/**
* Compares this {@code UncertainDouble} with another
* {@code UncertainDouble}.
@@ -156,10 +170,13 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
public final int compareTo(UncertainDouble o) {
return Double.compare(this.value, o.value);
}
-
+
/**
* Returns the quotient of {@code this} and {@code other}.
*
+ * @param other number to divide by
+ * @return quotient
+ *
* @since 2020-09-07
*/
public final UncertainDouble dividedBy(UncertainDouble other) {
@@ -167,16 +184,19 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
return UncertainDouble.ofRelative(this.value / other.value, Math
.hypot(this.relativeUncertainty(), other.relativeUncertainty()));
}
-
+
/**
* Returns the quotient of {@code this} and the exact value {@code other}.
*
+ * @param other number to divide by
+ * @return quotient
+ *
* @since 2020-09-07
*/
public final UncertainDouble dividedByExact(double other) {
return UncertainDouble.of(this.value / other, this.uncertainty / other);
}
-
+
@Override
public final boolean equals(Object obj) {
if (this == obj)
@@ -190,7 +210,7 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
return false;
return true;
}
-
+
/**
* @param other another {@code UncertainDouble}
* @return true iff this and {@code other} are within each other's
@@ -202,7 +222,7 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
return Math.abs(this.value - other.value) <= Math.min(this.uncertainty,
other.uncertainty);
}
-
+
/**
* Gets the preferred scale for rounding a value for toString.
*
@@ -217,19 +237,19 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
// the value is rounded to the same number of decimal places as the
// uncertainty.
final BigDecimal bigUncertainty = BigDecimal.valueOf(this.uncertainty);
-
+
// the scale that will give the uncertainty two decimal places
final int twoDecimalPlacesScale = bigUncertainty.scale()
- bigUncertainty.precision() + 2;
final BigDecimal roundedUncertainty = bigUncertainty
.setScale(twoDecimalPlacesScale, RoundingMode.HALF_EVEN);
-
+
if (roundedUncertainty.unscaledValue().intValue() >= 20)
return twoDecimalPlacesScale - 1; // one decimal place
else
return twoDecimalPlacesScale;
}
-
+
@Override
public final int hashCode() {
final int prime = 31;
@@ -238,7 +258,7 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
result = prime * result + Double.hashCode(this.uncertainty);
return result;
}
-
+
/**
* @return true iff the value has no uncertainty
*
@@ -247,10 +267,13 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
public final boolean isExact() {
return this.uncertainty == 0;
}
-
+
/**
* Returns the difference of {@code this} and {@code other}.
*
+ * @param other number to subtract
+ * @return result of subtraction
+ *
* @since 2020-09-07
*/
public final UncertainDouble minus(UncertainDouble other) {
@@ -258,19 +281,25 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
return UncertainDouble.of(this.value - other.value,
Math.hypot(this.uncertainty, other.uncertainty));
}
-
+
/**
* Returns the difference of {@code this} and the exact value {@code other}.
*
+ * @param other number to subtract
+ * @return result of subtraction
+ *
* @since 2020-09-07
*/
public final UncertainDouble minusExact(double other) {
return UncertainDouble.of(this.value - other, this.uncertainty);
}
-
+
/**
* Returns the sum of {@code this} and {@code other}.
*
+ * @param other number to add
+ * @return result of addition
+ *
* @since 2020-09-07
*/
public final UncertainDouble plus(UncertainDouble other) {
@@ -278,16 +307,19 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
return UncertainDouble.of(this.value + other.value,
Math.hypot(this.uncertainty, other.uncertainty));
}
-
+
/**
* Returns the sum of {@code this} and the exact value {@code other}.
*
+ * @param other number to add
+ * @return result of addition
+ *
* @since 2020-09-07
*/
public final UncertainDouble plusExact(double other) {
return UncertainDouble.of(this.value + other, this.uncertainty);
}
-
+
/**
* @return relative uncertainty
* @since 2020-09-07
@@ -295,10 +327,13 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
public final double relativeUncertainty() {
return this.uncertainty / this.value;
}
-
+
/**
* Returns the product of {@code this} and {@code other}.
*
+ * @param other number to multiply
+ * @return product
+ *
* @since 2020-09-07
*/
public final UncertainDouble times(UncertainDouble other) {
@@ -306,49 +341,58 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
return UncertainDouble.ofRelative(this.value * other.value, Math
.hypot(this.relativeUncertainty(), other.relativeUncertainty()));
}
-
+
/**
* Returns the product of {@code this} and the exact value {@code other}.
*
+ * @param other number to multiply
+ * @return product
+ *
* @since 2020-09-07
*/
public final UncertainDouble timesExact(double other) {
return UncertainDouble.of(this.value * other, this.uncertainty * other);
}
-
+
/**
* Returns the result of {@code this} raised to the exponent {@code other}.
*
+ * @param other exponent
+ * @return result of exponentation
+ *
* @since 2020-09-07
*/
public final UncertainDouble toExponent(UncertainDouble other) {
Objects.requireNonNull(other, "other may not be null");
-
+
final double result = Math.pow(this.value, other.value);
final double relativeUncertainty = Math.hypot(
other.value * this.relativeUncertainty(),
Math.log(this.value) * other.uncertainty);
-
+
return UncertainDouble.ofRelative(result, relativeUncertainty);
}
-
+
/**
* Returns the result of {@code this} raised the exact exponent
* {@code other}.
*
+ * @param other exponent
+ * @return result of exponentation
+ *
* @since 2020-09-07
*/
public final UncertainDouble toExponentExact(double other) {
return UncertainDouble.ofRelative(Math.pow(this.value, other),
this.relativeUncertainty() * other);
}
-
+
/**
* Returns a string representation of this {@code UncertainDouble}.
* <p>
- * This method returns the same value as {@link #toString(boolean, RoundingMode)},
- * but {@code showUncertainty} is true if and only if the uncertainty is
- * non-zero.
+ * This method returns the same value as
+ * {@link #toString(boolean, RoundingMode)}, but {@code showUncertainty} is
+ * true if and only if the uncertainty is non-zero.
*
* <p>
* Examples:
@@ -365,7 +409,7 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
public final String toString() {
return this.toString(!this.isExact(), RoundingMode.HALF_EVEN);
}
-
+
/**
* Returns a string representation of this {@code UncertainDouble}.
* <p>
@@ -392,36 +436,40 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
* UncertainDouble.of(-5.01, 0).toString(true) = "-5.01 ± 0.0"
* </pre>
*
+ * @param showUncertainty uncertainty is only shown if this parameter is true
+ * @param roundingMode how to round values
+ * @return string representation of this {@code UncertainDouble}
+ *
* @since 2020-09-07
*/
public final String toString(boolean showUncertainty,
RoundingMode roundingMode) {
String valueString, uncertaintyString;
-
+
// generate the string representation of value and uncertainty
if (this.isExact()) {
uncertaintyString = "0.0";
valueString = Double.toString(this.value);
-
+
} else {
// round the value and uncertainty according to getDisplayScale()
final BigDecimal bigValue = BigDecimal.valueOf(this.value);
final BigDecimal bigUncertainty = BigDecimal.valueOf(this.uncertainty);
-
+
final int displayScale = this.getDisplayScale();
final BigDecimal roundedUncertainty = bigUncertainty
.setScale(displayScale, roundingMode);
final BigDecimal roundedValue = bigValue.setScale(displayScale,
roundingMode);
-
+
valueString = roundedValue.toString();
uncertaintyString = roundedUncertainty.toString();
}
-
+
// return "value" or "value ± uncertainty" depending on showUncertainty
return valueString + (showUncertainty ? " ± " + uncertaintyString : "");
}
-
+
/**
* @return absolute uncertainty
* @since 2020-09-07
@@ -429,7 +477,7 @@ public final class UncertainDouble implements Comparable<UncertainDouble> {
public final double uncertainty() {
return this.uncertainty;
}
-
+
/**
* @return value without uncertainty
* @since 2020-09-07
diff --git a/src/main/java/sevenUnitsGUI/DefaultPrefixRepetitionRule.java b/src/main/java/sevenUnitsGUI/DefaultPrefixRepetitionRule.java
index 1fb2709..ccc9f1c 100644
--- a/src/main/java/sevenUnitsGUI/DefaultPrefixRepetitionRule.java
+++ b/src/main/java/sevenUnitsGUI/DefaultPrefixRepetitionRule.java
@@ -15,12 +15,14 @@ import sevenUnits.unit.UnitPrefix;
* @since 2020-08-26
*/
public enum DefaultPrefixRepetitionRule implements Predicate<List<UnitPrefix>> {
+ /** Prefix repetition is never allowed; only one prefix may be used. */
NO_REPETITION {
@Override
public boolean test(List<UnitPrefix> prefixes) {
return prefixes.size() <= 1;
}
},
+ /** Prefix repetition is always allowed, without restrictions. */
NO_RESTRICTION {
@Override
public boolean test(List<UnitPrefix> prefixes) {
diff --git a/src/main/java/sevenUnitsGUI/GridBagBuilder.java b/src/main/java/sevenUnitsGUI/GridBagBuilder.java
index fdbaee7..95fc094 100644
--- a/src/main/java/sevenUnitsGUI/GridBagBuilder.java
+++ b/src/main/java/sevenUnitsGUI/GridBagBuilder.java
@@ -418,6 +418,7 @@ final class GridBagBuilder {
/**
* @param anchor anchor to set
+ * @return this, so that you can chain methods
* @since 2018-11-30
* @since v0.1.0
*/
@@ -428,6 +429,7 @@ final class GridBagBuilder {
/**
* @param fill fill to set
+ * @return this, so that you can chain methods
* @since 2018-11-30
* @since v0.1.0
*/
@@ -438,6 +440,7 @@ final class GridBagBuilder {
/**
* @param insets insets to set
+ * @return this, so that you can chain methods
* @since 2018-11-30
* @since v0.1.0
*/
@@ -448,6 +451,7 @@ final class GridBagBuilder {
/**
* @param ipadx ipadx to set
+ * @return this, so that you can chain methods
* @since 2018-11-30
* @since v0.1.0
*/
@@ -458,6 +462,7 @@ final class GridBagBuilder {
/**
* @param ipady ipady to set
+ * @return this, so that you can chain methods
* @since 2018-11-30
* @since v0.1.0
*/
@@ -468,6 +473,7 @@ final class GridBagBuilder {
/**
* @param weightx weightx to set
+ * @return this, so that you can chain methods
* @since 2018-11-30
* @since v0.1.0
*/
@@ -478,6 +484,7 @@ final class GridBagBuilder {
/**
* @param weighty weighty to set
+ * @return this, so that you can chain methods
* @since 2018-11-30
* @since v0.1.0
*/
diff --git a/src/main/java/sevenUnitsGUI/Presenter.java b/src/main/java/sevenUnitsGUI/Presenter.java
index 44261a5..6dce39d 100644
--- a/src/main/java/sevenUnitsGUI/Presenter.java
+++ b/src/main/java/sevenUnitsGUI/Presenter.java
@@ -1280,6 +1280,8 @@ public final class Presenter {
/**
* Sets whether or not the default datafiles will be loaded.
* This method automatically updates the view's units.
+ *
+ * @param useDefaultDatafiles whether or not default datafiles should be loaded
*/
public void setUseDefaultDatafiles(boolean useDefaultDatafiles) {
this.useDefaultDatafiles = useDefaultDatafiles;
diff --git a/src/main/java/sevenUnitsGUI/StandardDisplayRules.java b/src/main/java/sevenUnitsGUI/StandardDisplayRules.java
index d00263b..ff9c64e 100644
--- a/src/main/java/sevenUnitsGUI/StandardDisplayRules.java
+++ b/src/main/java/sevenUnitsGUI/StandardDisplayRules.java
@@ -40,6 +40,7 @@ public final class StandardDisplayRules {
*/
public static final class FixedDecimals
implements Function<UncertainDouble, String> {
+ /** Regular expression used for converting this to a string. */
public static final Pattern TO_STRING_PATTERN = Pattern
.compile("Round to (\\d+) decimal places");
/**
@@ -101,6 +102,7 @@ public final class StandardDisplayRules {
*/
public static final class FixedPrecision
implements Function<UncertainDouble, String> {
+ /** Regular expression used for converting this to a string. */
public static final Pattern TO_STRING_PATTERN = Pattern
.compile("Round to (\\d+) significant figures");
diff --git a/src/main/java/sevenUnitsGUI/ViewBot.java b/src/main/java/sevenUnitsGUI/ViewBot.java
index aea30bb..60a8d7b 100644
--- a/src/main/java/sevenUnitsGUI/ViewBot.java
+++ b/src/main/java/sevenUnitsGUI/ViewBot.java
@@ -79,10 +79,12 @@ public final class ViewBot
return Objects.hash(this.multiplierString, this.nameSymbol);
}
+ /** @return A string representation of the prefix multiplier. */
public String multiplierString() {
return this.multiplierString;
}
+ /** @return A {@code NameSymbol} describing the prefix. */
public NameSymbol nameSymbol() {
return this.nameSymbol;
}
@@ -112,6 +114,10 @@ public final class ViewBot
private final UnitType unitType;
/**
+ * @param nameSymbol name(s) and symbol of unit
+ * @param definition unit's definition string
+ * @param dimensionName name of unit's dimension
+ * @param unitType type of unit (metric/semi-metric/non-metric)
* @since 2022-04-16
*/
public UnitViewingRecord(NameSymbol nameSymbol, String definition,
@@ -166,6 +172,7 @@ public final class ViewBot
this.nameSymbol, this.unitType);
}
+ /** @return name(s) and symbol of unit */
public NameSymbol nameSymbol() {
return this.nameSymbol;
}
@@ -395,6 +402,10 @@ public final class ViewBot
this.selectedDimensionName = selectedDimensionName;
}
+ /**
+ * Sets the view's selected dimension
+ * @param selectedDimensionName name of dimension to select (string)
+ */
public void setSelectedDimensionName(String selectedDimensionName) {
this.setSelectedDimensionName(Optional.of(selectedDimensionName));
}
@@ -412,7 +423,7 @@ public final class ViewBot
}
/**
- * @param toSelection the toSelection to set
+ * @param toSelection unit set in the 'To' selection
* @since 2022-01-29
*/
public void setToSelection(Optional<String> toSelection) {
@@ -420,6 +431,9 @@ public final class ViewBot
"toSelection cannot be null.");
}
+ /**
+ * @param toSelection unit set in the 'To' selection
+ */
public void setToSelection(String toSelection) {
this.setToSelection(Optional.of(toSelection));
}
@@ -439,18 +453,32 @@ public final class ViewBot
// do nothing, ViewBot supports selecting any unit
}
+ /**
+ * @param viewedPrefixName name of prefix being used
+ */
public void setViewedPrefixName(Optional<String> viewedPrefixName) {
this.prefixViewerSelection = viewedPrefixName;
}
+ /**
+ * @param viewedPrefixName name of prefix being used (may not be null)
+ * @throws NullPointerException if {@code viewedPrefixName} is null
+ */
public void setViewedPrefixName(String viewedPrefixName) {
this.setViewedPrefixName(Optional.of(viewedPrefixName));
}
+ /**
+ * @param viewedUnitName name of unit being used
+ */
public void setViewedUnitName(Optional<String> viewedUnitName) {
this.unitViewerSelection = viewedUnitName;
}
+ /**
+ * @param viewedUnitName name of unit being used (may not be null)
+ * @throws NullPointerException if {@code viewedUnitName} is null
+ */
public void setViewedUnitName(String viewedUnitName) {
this.setViewedUnitName(Optional.of(viewedUnitName));
}