This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git
The following commit(s) were added to refs/heads/master by this push:
new 9f47c9ca Pull up compareTo(Number, Number) from BigDecimalValidator to
AbstractNumberValidator
new ec803538 Merge branch 'master' of
https://github.com/apache/commons-validator.git
9f47c9ca is described below
commit 9f47c9ca4fb462be8e86a80afcec80938648db93
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 27 11:02:34 2026 +0000
Pull up compareTo(Number, Number) from BigDecimalValidator to
AbstractNumberValidator
See also PR 410.
---
.../routines/AbstractNumberValidator.java | 43 ++++++++++++++--------
.../validator/routines/BigDecimalValidator.java | 11 ------
2 files changed, 27 insertions(+), 27 deletions(-)
diff --git
a/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
b/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
index 8eb74ac2..4052ca8b 100644
---
a/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
+++
b/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
@@ -53,6 +53,33 @@ public abstract class AbstractNumberValidator extends
AbstractFormatValidator {
*/
public static final int PERCENT_FORMAT = 2;
+ /**
+ * Compares two values as BigDecimals.
+ *
+ * @param value1 {@code BigDecimal} to compare.
+ * @param value2 {@code BigDecimal} to which {@code value1} is to be
compared.
+ * @return -1, 0, or 1 as this {@code BigDecimal} is numerically less
than, equal to, or greater than {@code val}.
+ */
+ static int compareTo(final Number value1, final Number value2) {
+ return toBigDecimal(value1).compareTo(toBigDecimal(value2));
+ }
+
+ /**
+ * Tests if the given value is finite.
+ *
+ * @param value The value to test.
+ * @return {@code true} if the value is finite, {@code false} otherwise.
+ */
+ static boolean isFinite(final Number value) {
+ if (value instanceof Double) {
+ return Double.isFinite((Double) value);
+ }
+ if (value instanceof Float) {
+ return Float.isFinite((Float) value);
+ }
+ return true;
+ }
+
static Format setParseBigDecimal(final Format format) {
if (format instanceof DecimalFormat) {
((DecimalFormat) format).setParseBigDecimal(true);
@@ -84,22 +111,6 @@ public abstract class AbstractNumberValidator extends
AbstractFormatValidator {
return toBigDecimal(value).toBigInteger();
}
- /**
- * Tests if the given value is finite.
- *
- * @param value The value to test.
- * @return {@code true} if the value is finite, {@code false} otherwise.
- */
- static boolean isFinite(final Number value) {
- if (value instanceof Double) {
- return Double.isFinite((Double) value);
- }
- if (value instanceof Float) {
- return Float.isFinite((Float) value);
- }
- return true;
- }
-
/**
* {@code true} if fractions are allowed or {@code false} if integers only.
*/
diff --git
a/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
b/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
index 03c22bd4..0b94eb98 100644
---
a/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
+++
b/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
@@ -123,17 +123,6 @@ public class BigDecimalValidator extends
AbstractNumberValidator {
super(strict, formatType, allowFractions);
}
- /**
- * Compares two values as BigDecimals.
- *
- * @param value1 {@code BigDecimal} to compare.
- * @param value2 {@code BigDecimal} to which {@code value1} is to be
compared.
- * @return -1, 0, or 1 as this {@code BigDecimal} is numerically less
than, equal to, or greater than {@code val}.
- */
- private int compareTo(final Number value1, final Number value2) {
- return toBigDecimal(value1).compareTo(toBigDecimal(value2));
- }
-
/**
* Returns a {@code Format} that parses to a {@code BigDecimal} so the
exact value of the input is preserved.
*