MonetaryFormat: Implement equals() and hashCode().
@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Monetary;
@@ -451,4 +452,45 @@ public final class MonetaryFormat {
throw new NumberFormatException("missing code for shift: " + shift);
return codes[shift];
}
+
+ /**
+ * Two formats are equal if they have the same parameters.
+ */
+ @Override
+ public boolean equals(final Object o) {
+ if (o == this)
+ return true;
+ if (o == null || o.getClass() != getClass())
+ return false;
+ final MonetaryFormat other = (MonetaryFormat) o;
+ if (!Objects.equals(this.negativeSign, other.negativeSign))
+ return false;
+ if (!Objects.equals(this.positiveSign, other.positiveSign))
+ return false;
+ if (!Objects.equals(this.zeroDigit, other.zeroDigit))
+ return false;
+ if (!Objects.equals(this.decimalMark, other.decimalMark))
+ return false;
+ if (!Objects.equals(this.minDecimals, other.minDecimals))
+ return false;
+ if (!Objects.equals(this.decimalGroups, other.decimalGroups))
+ return false;
+ if (!Objects.equals(this.shift, other.shift))
+ return false;
+ if (!Objects.equals(this.roundingMode, other.roundingMode))
+ return false;
+ if (!Objects.equals(this.codes, other.codes))
+ return false;
+ if (!Objects.equals(this.codeSeparator, other.codeSeparator))
+ return false;
+ if (!Objects.equals(this.codePrefixed, other.codePrefixed))
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift,
+ roundingMode, codes, codeSeparator, codePrefixed);
+ }
}
