ICU-21249 Fixed some coding problems found by Spotbugs

See #1382
This commit is contained in:
Yoshito Umaoka 2020-09-30 18:13:38 +00:00
parent 54e7bace04
commit 8caba0e6c9
3 changed files with 8 additions and 9 deletions

View File

@ -128,7 +128,7 @@ public class UnitConverter {
assert (!factor.isEmpty());
// Remove all spaces in the factor
factor.replaceAll("\\s+", "");
factor = factor.replaceAll("\\s+", "");
String[] fractions = factor.split("/");
assert (fractions.length == 1 || fractions.length == 2);
@ -153,10 +153,9 @@ public class UnitConverter {
}
/**
* Clone this <code>Factor</code>.
* Copy this <code>Factor</code>.
*/
@Override
protected Factor clone() {
protected Factor copy() {
Factor result = new Factor();
result.factorNum = this.factorNum;
result.factorDen = this.factorDen;
@ -175,7 +174,7 @@ public class UnitConverter {
* Returns a single `BigDecimal` that represent the conversion rate after substituting all the constants.
*/
public BigDecimal getConversionRate() {
Factor resultCollector = this.clone();
Factor resultCollector = this.copy();
resultCollector.substitute(new BigDecimal("0.3048"), this.CONSTANT_FT2M);
resultCollector.substitute(new BigDecimal("411557987.0").divide(new BigDecimal("131002976.0"), DECIMAL128), this.CONSTANT_PI);
@ -199,7 +198,7 @@ public class UnitConverter {
}
public Factor applySiPrefix(MeasureUnit.SIPrefix siPrefix) {
Factor result = this.clone();
Factor result = this.copy();
if (siPrefix == MeasureUnit.SIPrefix.ONE) {
return result;
}

View File

@ -168,7 +168,7 @@ public class UnitsData {
@Override
public void put(UResource.Key key, UResource.Value value, boolean noFallback) {
assert (key.toString() == Constants.CATEGORY_TABLE_NAME);
assert (key.toString().equals(Constants.CATEGORY_TABLE_NAME));
assert (value.getType() == UResourceBundle.TABLE);
UResource.Table categoryTable = value.getTable();

View File

@ -1544,7 +1544,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
} else {
replacedRegion = replacement.get(0);
}
assert this.region != replacedRegion;
assert !this.region.equals(replacedRegion);
this.region = replacedRegion;
// The region is changed by data in territory alias.
return true;
@ -1557,7 +1557,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
// Found no replacement data for this script.
return false;
}
assert this.script != replacement;
assert !this.script.equals(replacement);
this.script = replacement;
// The script is changed by data in script alias.
return true;