From 7813a3840fea87bdc86e021366ecf2975b11cbff Mon Sep 17 00:00:00 2001
From: Gary Gregory
Date: Wed, 13 Sep 2023 18:30:59 -0400
Subject: [PATCH] Remove trailing whitespace
Use final
Use varargs
Remove extra parens
---
.../validator/CreditCardValidator.java | 17 +++----
.../commons/validator/DateValidator.java | 2 +-
.../commons/validator/EmailValidator.java | 2 +-
.../org/apache/commons/validator/Form.java | 2 +-
.../validator/GenericTypeValidator.java | 4 +-
.../commons/validator/GenericValidator.java | 50 +++++++++----------
.../commons/validator/UrlValidator.java | 6 +--
.../commons/validator/ValidatorAction.java | 4 +-
.../commons/validator/ValidatorResources.java | 6 +--
.../routines/AbstractCalendarValidator.java | 22 ++++----
.../routines/AbstractNumberValidator.java | 14 +++---
.../routines/BigDecimalValidator.java | 6 +--
.../routines/BigIntegerValidator.java | 6 +--
.../validator/routines/ByteValidator.java | 6 +--
.../validator/routines/CodeValidator.java | 6 +--
.../validator/routines/DomainValidator.java | 2 +-
.../validator/routines/DoubleValidator.java | 6 +--
.../validator/routines/EmailValidator.java | 2 +-
.../validator/routines/FloatValidator.java | 6 +--
.../validator/routines/IBANValidator.java | 4 +-
.../routines/InetAddressValidator.java | 10 ++--
.../validator/routines/IntegerValidator.java | 6 +--
.../validator/routines/LongValidator.java | 6 +--
.../validator/routines/RegexValidator.java | 2 +-
.../validator/routines/ShortValidator.java | 6 +--
.../validator/routines/UrlValidator.java | 4 +-
.../routines/checkdigit/CUSIPCheckDigit.java | 2 +-
.../routines/checkdigit/LuhnCheckDigit.java | 2 +-
.../checkdigit/ModulusCheckDigit.java | 2 +-
.../checkdigit/VerhoeffCheckDigit.java | 4 +-
.../commons/validator/AbstractNumberTest.java | 2 +-
.../validator/CreditCardValidatorTest.java | 2 +-
.../apache/commons/validator/DateTest.java | 2 +-
.../apache/commons/validator/EmailTest.java | 6 +--
.../validator/GenericTypeValidatorTest.java | 26 +++++-----
.../validator/GenericValidatorImpl.java | 10 ++--
.../org/apache/commons/validator/UrlTest.java | 4 +-
.../commons/validator/ValidatorTest.java | 2 +-
.../AbstractCalendarValidatorTest.java | 16 +++---
.../routines/CalendarValidatorTest.java | 2 +-
.../routines/CurrencyValidatorTest.java | 4 +-
.../validator/routines/DateValidatorTest.java | 2 +-
.../routines/DomainValidatorTest.java | 2 +-
.../routines/EmailValidatorTest.java | 4 +-
.../routines/FloatValidatorTest.java | 2 +-
.../validator/routines/IBANValidatorTest.java | 4 +-
.../routines/RegexValidatorTest.java | 10 ++--
.../validator/routines/TimeValidatorTest.java | 8 +--
.../validator/routines/UrlValidatorTest.java | 6 +--
49 files changed, 165 insertions(+), 166 deletions(-)
diff --git a/src/main/java/org/apache/commons/validator/CreditCardValidator.java b/src/main/java/org/apache/commons/validator/CreditCardValidator.java
index 68a4c2bbf..2b0bb6d22 100644
--- a/src/main/java/org/apache/commons/validator/CreditCardValidator.java
+++ b/src/main/java/org/apache/commons/validator/CreditCardValidator.java
@@ -134,7 +134,7 @@ public CreditCardValidator(final int options) {
* @return Whether the card number is valid.
*/
public boolean isValid(final String card) {
- if ((card == null) || (card.length() < 13) || (card.length() > 19)) {
+ if (card == null || card.length() < 13 || card.length() > 19) {
return false;
}
@@ -180,7 +180,7 @@ protected boolean luhnCheck(final String cardNumber) {
return false;
}
- if (((count & 1) ^ oddOrEven) == 0) { // not
+ if ((count & 1 ^ oddOrEven) == 0) { // not
digit *= 2;
if (digit > 9) {
digit -= 9;
@@ -189,7 +189,7 @@ protected boolean luhnCheck(final String cardNumber) {
sum += digit;
}
- return (sum == 0) ? false : (sum % 10 == 0);
+ return sum == 0 ? false : sum % 10 == 0;
}
/**
@@ -222,9 +222,8 @@ private static class Visa implements CreditCardType {
private static final String PREFIX = "4";
@Override
public boolean matches(final String card) {
- return (
- card.substring(0, 1).equals(PREFIX)
- && (card.length() == 13 || card.length() == 16));
+ return card.substring(0, 1).equals(PREFIX)
+ && (card.length() == 13 || card.length() == 16);
}
}
@@ -233,7 +232,7 @@ private static class Amex implements CreditCardType {
@Override
public boolean matches(final String card) {
final String prefix2 = card.substring(0, 2) + ",";
- return ((PREFIX.contains(prefix2)) && (card.length() == 15));
+ return PREFIX.contains(prefix2) && card.length() == 15;
}
}
@@ -241,7 +240,7 @@ private static class Discover implements CreditCardType {
private static final String PREFIX = "6011";
@Override
public boolean matches(final String card) {
- return (card.substring(0, 4).equals(PREFIX) && (card.length() == 16));
+ return card.substring(0, 4).equals(PREFIX) && card.length() == 16;
}
}
@@ -250,7 +249,7 @@ private static class Mastercard implements CreditCardType {
@Override
public boolean matches(final String card) {
final String prefix2 = card.substring(0, 2) + ",";
- return ((PREFIX.contains(prefix2)) && (card.length() == 16));
+ return PREFIX.contains(prefix2) && card.length() == 16;
}
}
diff --git a/src/main/java/org/apache/commons/validator/DateValidator.java b/src/main/java/org/apache/commons/validator/DateValidator.java
index 37517fa27..d8d4fca21 100644
--- a/src/main/java/org/apache/commons/validator/DateValidator.java
+++ b/src/main/java/org/apache/commons/validator/DateValidator.java
@@ -84,7 +84,7 @@ public boolean isValid(final String value, final String datePattern, final boole
return false;
}
- if (strict && (datePattern.length() != value.length())) {
+ if (strict && datePattern.length() != value.length()) {
return false;
}
diff --git a/src/main/java/org/apache/commons/validator/EmailValidator.java b/src/main/java/org/apache/commons/validator/EmailValidator.java
index 3c96c4cb6..45adcfdcd 100644
--- a/src/main/java/org/apache/commons/validator/EmailValidator.java
+++ b/src/main/java/org/apache/commons/validator/EmailValidator.java
@@ -174,7 +174,7 @@ protected boolean isValidSymbolicDomain(String domain) {
domainSegment[i] = atomMatcher.group(1);
final int l = domainSegment[i].length() + 1;
domain =
- (l >= domain.length())
+ l >= domain.length()
? ""
: domain.substring(l);
diff --git a/src/main/java/org/apache/commons/validator/Form.java b/src/main/java/org/apache/commons/validator/Form.java
index 1de7c98ad..f7a197a59 100644
--- a/src/main/java/org/apache/commons/validator/Form.java
+++ b/src/main/java/org/apache/commons/validator/Form.java
@@ -30,7 +30,7 @@
* This contains a set of validation rules for a form/JavaBean. The information
* is contained in a list of Field
objects. Instances of this class
* are configured with a <form> xml element.
- *
+ *
*
* The use of FastHashMap is deprecated and will be replaced in a future
* release.
diff --git a/src/main/java/org/apache/commons/validator/GenericTypeValidator.java b/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
index 40f17d627..0458ded37 100644
--- a/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
+++ b/src/main/java/org/apache/commons/validator/GenericTypeValidator.java
@@ -288,7 +288,7 @@ public static Float formatFloat(final String value, final Locale locale) {
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
- num.doubleValue() >= (Float.MAX_VALUE * -1) &&
+ num.doubleValue() >= Float.MAX_VALUE * -1 &&
num.doubleValue() <= Float.MAX_VALUE) {
result = Float.valueOf(num.floatValue());
}
@@ -339,7 +339,7 @@ public static Double formatDouble(final String value, final Locale locale) {
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
- num.doubleValue() >= (Double.MAX_VALUE * -1) &&
+ num.doubleValue() >= Double.MAX_VALUE * -1 &&
num.doubleValue() <= Double.MAX_VALUE) {
result = Double.valueOf(num.doubleValue());
}
diff --git a/src/main/java/org/apache/commons/validator/GenericValidator.java b/src/main/java/org/apache/commons/validator/GenericValidator.java
index 636a90aea..6dba8e780 100644
--- a/src/main/java/org/apache/commons/validator/GenericValidator.java
+++ b/src/main/java/org/apache/commons/validator/GenericValidator.java
@@ -76,7 +76,7 @@ public static boolean matchRegexp(final String value, final String regexp) {
* @return true if the value can be converted to a Byte.
*/
public static boolean isByte(final String value) {
- return (GenericTypeValidator.formatByte(value) != null);
+ return GenericTypeValidator.formatByte(value) != null;
}
/**
@@ -86,7 +86,7 @@ public static boolean isByte(final String value) {
* @return true if the value can be converted to a Short.
*/
public static boolean isShort(final String value) {
- return (GenericTypeValidator.formatShort(value) != null);
+ return GenericTypeValidator.formatShort(value) != null;
}
/**
@@ -96,7 +96,7 @@ public static boolean isShort(final String value) {
* @return true if the value can be converted to an Integer.
*/
public static boolean isInt(final String value) {
- return (GenericTypeValidator.formatInt(value) != null);
+ return GenericTypeValidator.formatInt(value) != null;
}
/**
@@ -106,7 +106,7 @@ public static boolean isInt(final String value) {
* @return true if the value can be converted to a Long.
*/
public static boolean isLong(final String value) {
- return (GenericTypeValidator.formatLong(value) != null);
+ return GenericTypeValidator.formatLong(value) != null;
}
/**
@@ -116,7 +116,7 @@ public static boolean isLong(final String value) {
* @return true if the value can be converted to a Float.
*/
public static boolean isFloat(final String value) {
- return (GenericTypeValidator.formatFloat(value) != null);
+ return GenericTypeValidator.formatFloat(value) != null;
}
/**
@@ -126,7 +126,7 @@ public static boolean isFloat(final String value) {
* @return true if the value can be converted to a Double.
*/
public static boolean isDouble(final String value) {
- return (GenericTypeValidator.formatDouble(value) != null);
+ return GenericTypeValidator.formatDouble(value) != null;
}
/**
@@ -170,7 +170,7 @@ public static boolean isDate(final String value, final String datePattern, final
* @return true if the value is in the specified range.
*/
public static boolean isInRange(final byte value, final byte min, final byte max) {
- return ((value >= min) && (value <= max));
+ return value >= min && value <= max;
}
/**
@@ -183,7 +183,7 @@ public static boolean isInRange(final byte value, final byte min, final byte max
* @return true if the value is in the specified range.
*/
public static boolean isInRange(final int value, final int min, final int max) {
- return ((value >= min) && (value <= max));
+ return value >= min && value <= max;
}
/**
@@ -196,7 +196,7 @@ public static boolean isInRange(final int value, final int min, final int max) {
* @return true if the value is in the specified range.
*/
public static boolean isInRange(final float value, final float min, final float max) {
- return ((value >= min) && (value <= max));
+ return value >= min && value <= max;
}
/**
@@ -209,7 +209,7 @@ public static boolean isInRange(final float value, final float min, final float
* @return true if the value is in the specified range.
*/
public static boolean isInRange(final short value, final short min, final short max) {
- return ((value >= min) && (value <= max));
+ return value >= min && value <= max;
}
/**
@@ -222,7 +222,7 @@ public static boolean isInRange(final short value, final short min, final short
* @return true if the value is in the specified range.
*/
public static boolean isInRange(final long value, final long min, final long max) {
- return ((value >= min) && (value <= max));
+ return value >= min && value <= max;
}
/**
@@ -235,7 +235,7 @@ public static boolean isInRange(final long value, final long min, final long max
* @return true if the value is in the specified range.
*/
public static boolean isInRange(final double value, final double min, final double max) {
- return ((value >= min) && (value <= max));
+ return value >= min && value <= max;
}
/**
@@ -277,7 +277,7 @@ public static boolean isUrl(final String value) {
* @return true if the value's length is less than the specified maximum.
*/
public static boolean maxLength(final String value, final int max) {
- return (value.length() <= max);
+ return value.length() <= max;
}
/**
@@ -290,7 +290,7 @@ public static boolean maxLength(final String value, final int max) {
*/
public static boolean maxLength(final String value, final int max, final int lineEndLength) {
final int adjustAmount = adjustForLineEnding(value, lineEndLength);
- return ((value.length() + adjustAmount) <= max);
+ return value.length() + adjustAmount <= max;
}
/**
@@ -301,7 +301,7 @@ public static boolean maxLength(final String value, final int max, final int lin
* @return true if the value's length is more than the specified minimum.
*/
public static boolean minLength(final String value, final int min) {
- return (value.length() >= min);
+ return value.length() >= min;
}
/**
@@ -314,7 +314,7 @@ public static boolean minLength(final String value, final int min) {
*/
public static boolean minLength(final String value, final int min, final int lineEndLength) {
final int adjustAmount = adjustForLineEnding(value, lineEndLength);
- return ((value.length() + adjustAmount) >= min);
+ return value.length() + adjustAmount >= min;
}
/**
@@ -337,7 +337,7 @@ private static int adjustForLineEnding(final String value, final int lineEndLeng
rCount++;
}
}
- return ((nCount * lineEndLength) - (rCount + nCount));
+ return nCount * lineEndLength - (rCount + nCount);
}
// See http://issues.apache.org/bugzilla/show_bug.cgi?id=29015 WRT the "value" methods
@@ -350,7 +350,7 @@ private static int adjustForLineEnding(final String value, final int lineEndLeng
* @return true if the value is >= the specified minimum.
*/
public static boolean minValue(final int value, final int min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -361,7 +361,7 @@ public static boolean minValue(final int value, final int min) {
* @return true if the value is >= the specified minimum.
*/
public static boolean minValue(final long value, final long min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -372,7 +372,7 @@ public static boolean minValue(final long value, final long min) {
* @return true if the value is >= the specified minimum.
*/
public static boolean minValue(final double value, final double min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -383,7 +383,7 @@ public static boolean minValue(final double value, final double min) {
* @return true if the value is >= the specified minimum.
*/
public static boolean minValue(final float value, final float min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -394,7 +394,7 @@ public static boolean minValue(final float value, final float min) {
* @return true if the value is <= the specified maximum.
*/
public static boolean maxValue(final int value, final int max) {
- return (value <= max);
+ return value <= max;
}
/**
@@ -405,7 +405,7 @@ public static boolean maxValue(final int value, final int max) {
* @return true if the value is <= the specified maximum.
*/
public static boolean maxValue(final long value, final long max) {
- return (value <= max);
+ return value <= max;
}
/**
@@ -416,7 +416,7 @@ public static boolean maxValue(final long value, final long max) {
* @return true if the value is <= the specified maximum.
*/
public static boolean maxValue(final double value, final double max) {
- return (value <= max);
+ return value <= max;
}
/**
@@ -427,7 +427,7 @@ public static boolean maxValue(final double value, final double max) {
* @return true if the value is <= the specified maximum.
*/
public static boolean maxValue(final float value, final float max) {
- return (value <= max);
+ return value <= max;
}
}
diff --git a/src/main/java/org/apache/commons/validator/UrlValidator.java b/src/main/java/org/apache/commons/validator/UrlValidator.java
index 1c6bcf3e6..57595b465 100644
--- a/src/main/java/org/apache/commons/validator/UrlValidator.java
+++ b/src/main/java/org/apache/commons/validator/UrlValidator.java
@@ -352,7 +352,7 @@ protected boolean isValidAuthority(final String authority) {
domainSegment[segmentCount] = atomMatcher.group(1);
segmentLength = domainSegment[segmentCount].length() + 1;
hostIP =
- (segmentLength >= hostIP.length())
+ segmentLength >= hostIP.length()
? ""
: hostIP.substring(segmentLength);
@@ -407,13 +407,13 @@ protected boolean isValidPath(final String path) {
}
final int slash2Count = countToken("//", path);
- if (options.isOff(ALLOW_2_SLASHES) && (slash2Count > 0)) {
+ if (options.isOff(ALLOW_2_SLASHES) && slash2Count > 0) {
return false;
}
final int slashCount = countToken("/", path);
final int dot2Count = countToken("..", path);
- if (dot2Count > 0 && (slashCount - slash2Count - 1) <= dot2Count){
+ if (dot2Count > 0 && slashCount - slash2Count - 1 <= dot2Count){
return false;
}
diff --git a/src/main/java/org/apache/commons/validator/ValidatorAction.java b/src/main/java/org/apache/commons/validator/ValidatorAction.java
index 12f1a483b..6a8c26924 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorAction.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorAction.java
@@ -459,7 +459,7 @@ private String formatJavascriptFileName() {
* @return true if the javascript for this action has already been loaded.
*/
private boolean javascriptAlreadyLoaded() {
- return (this.javascript != null);
+ return this.javascript != null;
}
/**
@@ -564,7 +564,7 @@ boolean executeValidationMethod(
}
final boolean valid = this.isValid(result);
- if (!valid || (valid && !onlyReturnErrors(params))) {
+ if (!valid || valid && !onlyReturnErrors(params)) {
results.add(field, this.name, valid, result);
}
diff --git a/src/main/java/org/apache/commons/validator/ValidatorResources.java b/src/main/java/org/apache/commons/validator/ValidatorResources.java
index f63cea14d..95712791b 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorResources.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorResources.java
@@ -398,9 +398,9 @@ protected String buildKey(final FormSet fs) {
* Assembles a Locale code from the given parts.
*/
private String buildLocale(final String lang, final String country, final String variant) {
- String key = ((lang != null && !lang.isEmpty()) ? lang : "");
- key += ((country != null && !country.isEmpty()) ? "_" + country : "");
- key += ((variant != null && !variant.isEmpty()) ? "_" + variant : "");
+ String key = lang != null && !lang.isEmpty() ? lang : "";
+ key += country != null && !country.isEmpty() ? "_" + country : "";
+ key += variant != null && !variant.isEmpty() ? "_" + variant : "";
return key;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java b/src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java
index 614756521..0b9bcf7d5 100644
--- a/src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java
@@ -66,7 +66,7 @@ public AbstractCalendarValidator(final boolean strict, final int dateStyle, fina
@Override
public boolean isValid(final String value, final String pattern, final Locale locale) {
final Object parsedValue = parse(value, pattern, locale, (TimeZone)null);
- return (parsedValue == null ? false : true);
+ return parsedValue == null ? false : true;
}
/**
@@ -175,7 +175,7 @@ protected String format(Object value, final Format formatter) {
*/
protected Object parse(String value, final String pattern, final Locale locale, final TimeZone timeZone) {
- value = (value == null ? null : value.trim());
+ value = value == null ? null : value.trim();
if (value == null || value.isEmpty()) {
return null;
}
@@ -304,9 +304,9 @@ protected int compare(final Calendar value, final Calendar compare, final int fi
// Compare Date
result = calculateCompareResult(value, compare, Calendar.DATE);
- if (result != 0 || (field == Calendar.DATE ||
+ if (result != 0 || field == Calendar.DATE ||
field == Calendar.DAY_OF_WEEK ||
- field == Calendar.DAY_OF_WEEK_IN_MONTH)) {
+ field == Calendar.DAY_OF_WEEK_IN_MONTH) {
return result;
}
@@ -333,7 +333,7 @@ protected int compareTime(final Calendar value, final Calendar compare, final in
// Compare Hour
result = calculateCompareResult(value, compare, Calendar.HOUR_OF_DAY);
- if (result != 0 || (field == Calendar.HOUR || field == Calendar.HOUR_OF_DAY)) {
+ if (result != 0 || field == Calendar.HOUR || field == Calendar.HOUR_OF_DAY) {
return result;
}
@@ -391,16 +391,16 @@ private int calculateQuarter(final Calendar calendar, final int monthOfFirstQuar
// Add Year
int year = calendar.get(Calendar.YEAR);
- final int month = (calendar.get(Calendar.MONTH) + 1);
- final int relativeMonth = (month >= monthOfFirstQuarter)
- ? (month - monthOfFirstQuarter)
- : (month + (12 - monthOfFirstQuarter)); // CHECKSTYLE IGNORE MagicNumber
- final int quarter = ((relativeMonth / 3) + 1); // CHECKSTYLE IGNORE MagicNumber
+ final int month = calendar.get(Calendar.MONTH) + 1;
+ final int relativeMonth = month >= monthOfFirstQuarter
+ ? month - monthOfFirstQuarter
+ : month + 12 - monthOfFirstQuarter; // CHECKSTYLE IGNORE MagicNumber
+ final int quarter = relativeMonth / 3 + 1; // CHECKSTYLE IGNORE MagicNumber
// adjust the year if the quarter doesn't start in January
if (month < monthOfFirstQuarter) {
--year;
}
- return (year * 10) + quarter; // CHECKSTYLE IGNORE MagicNumber
+ return year * 10 + quarter; // CHECKSTYLE IGNORE MagicNumber
}
/**
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 7bbf099bf..3b931f69f 100644
--- a/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java
@@ -96,7 +96,7 @@ public int getFormatType() {
@Override
public boolean isValid(final String value, final String pattern, final Locale locale) {
final Object parsedValue = parse(value, pattern, locale);
- return (parsedValue == null ? false : true);
+ return parsedValue == null ? false : true;
}
/**
@@ -109,7 +109,7 @@ public boolean isValid(final String value, final String pattern, final Locale lo
* specified range.
*/
public boolean isInRange(final Number value, final Number min, final Number max) {
- return (minValue(value, min) && maxValue(value, max));
+ return minValue(value, min) && maxValue(value, max);
}
/**
@@ -122,9 +122,9 @@ public boolean isInRange(final Number value, final Number min, final Number max)
*/
public boolean minValue(final Number value, final Number min) {
if (isAllowFractions()) {
- return (value.doubleValue() >= min.doubleValue());
+ return value.doubleValue() >= min.doubleValue();
}
- return (value.longValue() >= min.longValue());
+ return value.longValue() >= min.longValue();
}
/**
@@ -137,9 +137,9 @@ public boolean minValue(final Number value, final Number min) {
*/
public boolean maxValue(final Number value, final Number max) {
if (isAllowFractions()) {
- return (value.doubleValue() <= max.doubleValue());
+ return value.doubleValue() <= max.doubleValue();
}
- return (value.longValue() <= max.longValue());
+ return value.longValue() <= max.longValue();
}
/**
@@ -153,7 +153,7 @@ public boolean maxValue(final Number value, final Number max) {
*/
protected Object parse(String value, final String pattern, final Locale locale) {
- value = (value == null ? null : value.trim());
+ value = value == null ? null : value.trim();
if (value == null || value.isEmpty()) {
return null;
}
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 2390b6a5e..81e298904 100644
--- a/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/BigDecimalValidator.java
@@ -185,7 +185,7 @@ public BigDecimal validate(final String value, final String pattern, final Local
* specified range.
*/
public boolean isInRange(final BigDecimal value, final double min, final double max) {
- return (value.doubleValue() >= min && value.doubleValue() <= max);
+ return value.doubleValue() >= min && value.doubleValue() <= max;
}
/**
@@ -197,7 +197,7 @@ public boolean isInRange(final BigDecimal value, final double min, final double
* or equal to the minimum.
*/
public boolean minValue(final BigDecimal value, final double min) {
- return (value.doubleValue() >= min);
+ return value.doubleValue() >= min;
}
/**
@@ -209,7 +209,7 @@ public boolean minValue(final BigDecimal value, final double min) {
* or equal to the maximum.
*/
public boolean maxValue(final BigDecimal value, final double max) {
- return (value.doubleValue() <= max);
+ return value.doubleValue() <= max;
}
/**
diff --git a/src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java b/src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java
index 33b67da06..190a32073 100644
--- a/src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java
@@ -168,7 +168,7 @@ public BigInteger validate(final String value, final String pattern, final Local
* specified range.
*/
public boolean isInRange(final BigInteger value, final long min, final long max) {
- return (value.longValue() >= min && value.longValue() <= max);
+ return value.longValue() >= min && value.longValue() <= max;
}
/**
@@ -180,7 +180,7 @@ public boolean isInRange(final BigInteger value, final long min, final long max)
* or equal to the minimum.
*/
public boolean minValue(final BigInteger value, final long min) {
- return (value.longValue() >= min);
+ return value.longValue() >= min;
}
/**
@@ -192,7 +192,7 @@ public boolean minValue(final BigInteger value, final long min) {
* or equal to the maximum.
*/
public boolean maxValue(final BigInteger value, final long max) {
- return (value.longValue() <= max);
+ return value.longValue() <= max;
}
/**
diff --git a/src/main/java/org/apache/commons/validator/routines/ByteValidator.java b/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
index e237c9dbd..476bf12bf 100644
--- a/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/ByteValidator.java
@@ -167,7 +167,7 @@ public Byte validate(final String value, final String pattern, final Locale loca
* specified range.
*/
public boolean isInRange(final byte value, final byte min, final byte max) {
- return (value >= min && value <= max);
+ return value >= min && value <= max;
}
/**
@@ -192,7 +192,7 @@ public boolean isInRange(final Byte value, final byte min, final byte max) {
* or equal to the minimum.
*/
public boolean minValue(final byte value, final byte min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -216,7 +216,7 @@ public boolean minValue(final Byte value, final byte min) {
* or equal to the maximum.
*/
public boolean maxValue(final byte value, final byte max) {
- return (value <= max);
+ return value <= max;
}
/**
diff --git a/src/main/java/org/apache/commons/validator/routines/CodeValidator.java b/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
index e58ebbdc9..a168b5295 100644
--- a/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/CodeValidator.java
@@ -230,7 +230,7 @@ public RegexValidator getRegexValidator() {
* {@code false}
*/
public boolean isValid(final String input) {
- return (validate(input) != null);
+ return validate(input) != null;
}
/**
@@ -265,8 +265,8 @@ public Object validate(final String input) {
}
// check the length (must be done after validate as that can change the code)
- if ((minLength >= 0 && code.length() < minLength) ||
- (maxLength >= 0 && code.length() > maxLength)) {
+ if (minLength >= 0 && code.length() < minLength ||
+ maxLength >= 0 && code.length() > maxLength) {
return null;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/DomainValidator.java b/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
index d007b2db8..8defc0434 100644
--- a/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
@@ -302,7 +302,7 @@ final boolean isValidDomainSyntax(String domain) {
return false;
}
final String[] groups = domainRegex.match(domain);
- return (groups != null && groups.length > 0)
+ return groups != null && groups.length > 0
|| hostnameRegex.isValid(domain);
}
diff --git a/src/main/java/org/apache/commons/validator/routines/DoubleValidator.java b/src/main/java/org/apache/commons/validator/routines/DoubleValidator.java
index acf312d1e..2fdccbc3c 100644
--- a/src/main/java/org/apache/commons/validator/routines/DoubleValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/DoubleValidator.java
@@ -167,7 +167,7 @@ public Double validate(final String value, final String pattern, final Locale lo
* specified range.
*/
public boolean isInRange(final double value, final double min, final double max) {
- return (value >= min && value <= max);
+ return value >= min && value <= max;
}
/**
@@ -192,7 +192,7 @@ public boolean isInRange(final Double value, final double min, final double max)
* or equal to the minimum.
*/
public boolean minValue(final double value, final double min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -216,7 +216,7 @@ public boolean minValue(final Double value, final double min) {
* or equal to the maximum.
*/
public boolean maxValue(final double value, final double max) {
- return (value <= max);
+ return value <= max;
}
/**
diff --git a/src/main/java/org/apache/commons/validator/routines/EmailValidator.java b/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
index 14a996d9f..32d2a5d95 100644
--- a/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
@@ -211,7 +211,7 @@ protected boolean isValidDomain(final String domain) {
}
// Domain is symbolic name
if (allowTld) {
- return domainValidator.isValid(domain) || (!domain.startsWith(".") && domainValidator.isValidTld(domain));
+ return domainValidator.isValid(domain) || !domain.startsWith(".") && domainValidator.isValidTld(domain);
}
return domainValidator.isValid(domain);
}
diff --git a/src/main/java/org/apache/commons/validator/routines/FloatValidator.java b/src/main/java/org/apache/commons/validator/routines/FloatValidator.java
index 97ad3781f..9a5912f04 100644
--- a/src/main/java/org/apache/commons/validator/routines/FloatValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/FloatValidator.java
@@ -167,7 +167,7 @@ public Float validate(final String value, final String pattern, final Locale loc
* specified range.
*/
public boolean isInRange(final float value, final float min, final float max) {
- return (value >= min && value <= max);
+ return value >= min && value <= max;
}
/**
@@ -192,7 +192,7 @@ public boolean isInRange(final Float value, final float min, final float max) {
* or equal to the minimum.
*/
public boolean minValue(final float value, final float min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -216,7 +216,7 @@ public boolean minValue(final Float value, final float min) {
* or equal to the maximum.
*/
public boolean maxValue(final float value, final float max) {
- return (value <= max);
+ return value <= max;
}
/**
diff --git a/src/main/java/org/apache/commons/validator/routines/IBANValidator.java b/src/main/java/org/apache/commons/validator/routines/IBANValidator.java
index b8263349b..c9b49c7ac 100644
--- a/src/main/java/org/apache/commons/validator/routines/IBANValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/IBANValidator.java
@@ -91,7 +91,7 @@ public Validator(final String countryCode, final int ibanLength, final String re
* @param ibanLength the length of the IBAN
* @param regexWithoutCC the regex to use to check the format, the regex MUST NOT start with the country code.
*/
- Validator(final String countryCode, final int ibanLength, final String regexWithoutCC, String... otherCountryCodes) {
+ Validator(final String countryCode, final int ibanLength, final String regexWithoutCC, final String... otherCountryCodes) {
if (!(countryCode.length() == 2 && Character.isUpperCase(countryCode.charAt(0)) && Character.isUpperCase(countryCode.charAt(1)))) {
throw new IllegalArgumentException("Invalid country Code; must be exactly 2 upper-case characters");
}
@@ -104,7 +104,7 @@ public Validator(final String countryCode, final int ibanLength, final String re
}
this.countryCode = countryCode;
this.otherCountryCodes = otherCountryCodes.clone();
- List regexList = new ArrayList<>(this.otherCountryCodes.length + 1);
+ final List regexList = new ArrayList<>(this.otherCountryCodes.length + 1);
regexList.add(countryCode + regexWithoutCC);
for (String otherCc : otherCountryCodes) {
regexList.add(otherCc + regexWithoutCC);
diff --git a/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java b/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
index 360d69d98..a7a7bd6d1 100644
--- a/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
@@ -149,16 +149,16 @@ public boolean isValidInet6Address(String inet6Address) {
}
// The id syntax is implementation independent, but it presumably cannot allow:
// whitespace, '/' or '%'
- if ((parts.length == 2) && !parts[1].matches("[^\\s/%]+")) {
+ if (parts.length == 2 && !parts[1].matches("[^\\s/%]+")) {
return false; // invalid id
}
inet6Address = parts[0];
final boolean containsCompressedZeroes = inet6Address.contains("::");
- if (containsCompressedZeroes && (inet6Address.indexOf("::") != inet6Address.lastIndexOf("::"))) {
+ if (containsCompressedZeroes && inet6Address.indexOf("::") != inet6Address.lastIndexOf("::")) {
return false;
}
- if ((inet6Address.startsWith(":") && !inet6Address.startsWith("::"))
- || (inet6Address.endsWith(":") && !inet6Address.endsWith("::"))) {
+ if (inet6Address.startsWith(":") && !inet6Address.startsWith("::")
+ || inet6Address.endsWith(":") && !inet6Address.endsWith("::")) {
return false;
}
String[] octets = inet6Address.split(":");
@@ -209,7 +209,7 @@ public boolean isValidInet6Address(String inet6Address) {
}
validOctets++;
}
- if (validOctets > IPV6_MAX_HEX_GROUPS || (validOctets < IPV6_MAX_HEX_GROUPS && !containsCompressedZeroes)) {
+ if (validOctets > IPV6_MAX_HEX_GROUPS || validOctets < IPV6_MAX_HEX_GROUPS && !containsCompressedZeroes) {
return false;
}
return true;
diff --git a/src/main/java/org/apache/commons/validator/routines/IntegerValidator.java b/src/main/java/org/apache/commons/validator/routines/IntegerValidator.java
index 34b51c8ed..87cbb6259 100644
--- a/src/main/java/org/apache/commons/validator/routines/IntegerValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/IntegerValidator.java
@@ -167,7 +167,7 @@ public Integer validate(final String value, final String pattern, final Locale l
* specified range.
*/
public boolean isInRange(final int value, final int min, final int max) {
- return (value >= min && value <= max);
+ return value >= min && value <= max;
}
/**
@@ -192,7 +192,7 @@ public boolean isInRange(final Integer value, final int min, final int max) {
* or equal to the minimum.
*/
public boolean minValue(final int value, final int min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -216,7 +216,7 @@ public boolean minValue(final Integer value, final int min) {
* or equal to the maximum.
*/
public boolean maxValue(final int value, final int max) {
- return (value <= max);
+ return value <= max;
}
/**
diff --git a/src/main/java/org/apache/commons/validator/routines/LongValidator.java b/src/main/java/org/apache/commons/validator/routines/LongValidator.java
index 8ee9d8a0a..335f98db7 100644
--- a/src/main/java/org/apache/commons/validator/routines/LongValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/LongValidator.java
@@ -166,7 +166,7 @@ public Long validate(final String value, final String pattern, final Locale loca
* specified range.
*/
public boolean isInRange(final long value, final long min, final long max) {
- return (value >= min && value <= max);
+ return value >= min && value <= max;
}
/**
@@ -191,7 +191,7 @@ public boolean isInRange(final Long value, final long min, final long max) {
* or equal to the minimum.
*/
public boolean minValue(final long value, final long min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -215,7 +215,7 @@ public boolean minValue(final Long value, final long min) {
* or equal to the maximum.
*/
public boolean maxValue(final long value, final long max) {
- return (value <= max);
+ return value <= max;
}
/**
diff --git a/src/main/java/org/apache/commons/validator/routines/RegexValidator.java b/src/main/java/org/apache/commons/validator/routines/RegexValidator.java
index 2ea27da3f..341aebbf9 100644
--- a/src/main/java/org/apache/commons/validator/routines/RegexValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/RegexValidator.java
@@ -133,7 +133,7 @@ public RegexValidator(final String[] regexs, final boolean caseSensitive) {
throw new IllegalArgumentException("Regular expressions are missing");
}
patterns = new Pattern[regexs.length];
- final int flags = (caseSensitive ? 0 : Pattern.CASE_INSENSITIVE);
+ final int flags = caseSensitive ? 0 : Pattern.CASE_INSENSITIVE;
for (int i = 0; i < regexs.length; i++) {
if (regexs[i] == null || regexs[i].isEmpty()) {
throw new IllegalArgumentException("Regular expression[" + i + "] is missing");
diff --git a/src/main/java/org/apache/commons/validator/routines/ShortValidator.java b/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
index 65d97f53c..a4cc0441f 100644
--- a/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/ShortValidator.java
@@ -167,7 +167,7 @@ public Short validate(final String value, final String pattern, final Locale loc
* specified range.
*/
public boolean isInRange(final short value, final short min, final short max) {
- return (value >= min && value <= max);
+ return value >= min && value <= max;
}
/**
@@ -192,7 +192,7 @@ public boolean isInRange(final Short value, final short min, final short max) {
* or equal to the minimum.
*/
public boolean minValue(final short value, final short min) {
- return (value >= min);
+ return value >= min;
}
/**
@@ -216,7 +216,7 @@ public boolean minValue(final Short value, final short min) {
* or equal to the maximum.
*/
public boolean maxValue(final short value, final short max) {
- return (value <= max);
+ return value <= max;
}
/**
diff --git a/src/main/java/org/apache/commons/validator/routines/UrlValidator.java b/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
index 9b0258db3..f2e7d647f 100644
--- a/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
@@ -265,7 +265,7 @@ public UrlValidator(String[] schemes, final RegexValidator authorityValidator, f
if (domainValidator == null) {
throw new IllegalArgumentException("DomainValidator must not be null");
}
- if (domainValidator.isAllowLocal() != ((options & ALLOW_LOCAL_URLS) > 0)){
+ if (domainValidator.isAllowLocal() != (options & ALLOW_LOCAL_URLS) > 0){
throw new IllegalArgumentException("DomainValidator disagrees with ALLOW_LOCAL_URLS setting");
}
this.domainValidator = domainValidator;
@@ -459,7 +459,7 @@ protected boolean isValidPath(final String path) {
}
final int slash2Count = countToken("//", path);
- if (isOff(ALLOW_2_SLASHES) && (slash2Count > 0)) {
+ if (isOff(ALLOW_2_SLASHES) && slash2Count > 0) {
return false;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
index e32d757bf..f8fe96d6f 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/CUSIPCheckDigit.java
@@ -93,7 +93,7 @@ protected int toInt(final char character, final int leftPos, final int rightPos)
@Override
protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
final int weight = POSITION_WEIGHT[rightPos % 2];
- final int weightedValue = (charValue * weight);
+ final int weightedValue = charValue * weight;
return ModulusCheckDigit.sumDigits(weightedValue);
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
index 41ed02c30..d78e80141 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.java
@@ -70,6 +70,6 @@ public LuhnCheckDigit() {
protected int weightedValue(final int charValue, final int leftPos, final int rightPos) {
final int weight = POSITION_WEIGHT[rightPos % 2]; // CHECKSTYLE IGNORE MagicNumber
final int weightedValue = charValue * weight;
- return weightedValue > 9 ? (weightedValue - 9) : weightedValue; // CHECKSTYLE IGNORE MagicNumber
+ return weightedValue > 9 ? weightedValue - 9 : weightedValue; // CHECKSTYLE IGNORE MagicNumber
}
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
index 50ee7a7ae..515692d30 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.java
@@ -72,7 +72,7 @@ public boolean isValid(final String code) {
}
try {
final int modulusResult = calculateModulus(code, true);
- return (modulusResult == 0);
+ return modulusResult == 0;
} catch (final CheckDigitException ex) {
return false;
}
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/VerhoeffCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/VerhoeffCheckDigit.java
index 3050f3a42..510a16363 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/VerhoeffCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/VerhoeffCheckDigit.java
@@ -78,7 +78,7 @@ public boolean isValid(final String code) {
return false;
}
try {
- return (calculateChecksum(code, true) == 0);
+ return calculateChecksum(code, true) == 0;
} catch (final CheckDigitException e) {
return false;
}
@@ -116,7 +116,7 @@ private int calculateChecksum(final String code, final boolean includesCheckDigi
final int num = Character.getNumericValue(code.charAt(idx));
if (num < 0 || num > 9) { // CHECKSTYLE IGNORE MagicNumber
throw new CheckDigitException("Invalid Character[" +
- i + "] = '" + ((int)code.charAt(idx)) + "'");
+ i + "] = '" + (int)code.charAt(idx) + "'");
}
final int pos = includesCheckDigit ? i : i + 1;
checksum = D_TABLE[checksum][P_TABLE[pos % 8][num]]; // CHECKSTYLE IGNORE MagicNumber
diff --git a/src/test/java/org/apache/commons/validator/AbstractNumberTest.java b/src/test/java/org/apache/commons/validator/AbstractNumberTest.java
index 3fb67bfc0..114ea5998 100644
--- a/src/test/java/org/apache/commons/validator/AbstractNumberTest.java
+++ b/src/test/java/org/apache/commons/validator/AbstractNumberTest.java
@@ -101,7 +101,7 @@ protected void valueTest(final Object info, final boolean passed) throws Validat
assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION + "' action.", result.containsAction(ACTION));
- assertTrue(ACTION + " value ValidatorResult for the '" + ACTION + "' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
+ assertTrue(ACTION + " value ValidatorResult for the '" + ACTION + "' action should have " + (passed ? "passed" : "failed") + ".", passed ? result.isValid(ACTION) : !result.isValid(ACTION));
}
diff --git a/src/test/java/org/apache/commons/validator/CreditCardValidatorTest.java b/src/test/java/org/apache/commons/validator/CreditCardValidatorTest.java
index c1afe8e59..390ab8a96 100644
--- a/src/test/java/org/apache/commons/validator/CreditCardValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/CreditCardValidatorTest.java
@@ -81,7 +81,7 @@ private static class DinersClub implements CreditCardValidator.CreditCardType {
@Override
public boolean matches(final String card) {
final String prefix = card.substring(0, 3) + ",";
- return ((PREFIX.contains(prefix)) && (card.length() == 14));
+ return PREFIX.contains(prefix) && card.length() == 14;
}
}
diff --git a/src/test/java/org/apache/commons/validator/DateTest.java b/src/test/java/org/apache/commons/validator/DateTest.java
index feddd33b6..9a6bdcaa6 100644
--- a/src/test/java/org/apache/commons/validator/DateTest.java
+++ b/src/test/java/org/apache/commons/validator/DateTest.java
@@ -101,7 +101,7 @@ protected void valueTest(final Object info, final boolean passed) throws Validat
assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION + "' action.", result.containsAction(ACTION));
- assertTrue(ACTION + " value ValidatorResult for the '" + ACTION + "' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
+ assertTrue(ACTION + " value ValidatorResult for the '" + ACTION + "' action should have " + (passed ? "passed" : "failed") + ".", passed ? result.isValid(ACTION) : !result.isValid(ACTION));
}
diff --git a/src/test/java/org/apache/commons/validator/EmailTest.java b/src/test/java/org/apache/commons/validator/EmailTest.java
index ef00c1f0a..b927575ea 100644
--- a/src/test/java/org/apache/commons/validator/EmailTest.java
+++ b/src/test/java/org/apache/commons/validator/EmailTest.java
@@ -208,9 +208,9 @@ public void testEmailWithSpaces() throws ValidatorException {
public void testEmailWithControlChars() {
final EmailValidator validator = new EmailValidator();
for (char c = 0; c < 32; c++) {
- assertFalse("Test control char " + ((int)c), validator.isValid("foo" + c + "bar@domain.com"));
+ assertFalse("Test control char " + (int)c, validator.isValid("foo" + c + "bar@domain.com"));
}
- assertFalse("Test control char 127", validator.isValid("foo" + ((char)127) + "bar@domain.com"));
+ assertFalse("Test control char 127", validator.isValid("foo" + (char)127 + "bar@domain.com"));
}
/**
@@ -441,6 +441,6 @@ private void valueTest(final ValueBean info, final boolean passed) throws Valida
assertNotNull(ACTION + " value ValidatorResult should not be null.", result);
assertTrue("Value "+info.getValue()+" ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION));
- assertTrue("Value "+info.getValue()+"ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION)));
+ assertTrue("Value "+info.getValue()+"ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", passed ? result.isValid(ACTION) : !result.isValid(ACTION));
}
}
diff --git a/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java b/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
index ad1e908e9..326ffea7e 100644
--- a/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/GenericTypeValidatorTest.java
@@ -88,12 +88,12 @@ public void testType() throws ValidatorException {
final Map hResultValues = results.getResultValueMap();
- assertTrue("Expecting byte result to be an instance of Byte.", (hResultValues.get("byte") instanceof Byte));
- assertTrue("Expecting short result to be an instance of Short.", (hResultValues.get("short") instanceof Short));
- assertTrue("Expecting integer result to be an instance of Integer.", (hResultValues.get("integer") instanceof Integer));
- assertTrue("Expecting long result to be an instance of Long.", (hResultValues.get("long") instanceof Long));
- assertTrue("Expecting float result to be an instance of Float.", (hResultValues.get("float") instanceof Float));
- assertTrue("Expecting double result to be an instance of Double.", (hResultValues.get("double") instanceof Double));
+ assertTrue("Expecting byte result to be an instance of Byte.", hResultValues.get("byte") instanceof Byte);
+ assertTrue("Expecting short result to be an instance of Short.", hResultValues.get("short") instanceof Short);
+ assertTrue("Expecting integer result to be an instance of Integer.", hResultValues.get("integer") instanceof Integer);
+ assertTrue("Expecting long result to be an instance of Long.", hResultValues.get("long") instanceof Long);
+ assertTrue("Expecting float result to be an instance of Float.", hResultValues.get("float") instanceof Float);
+ assertTrue("Expecting double result to be an instance of Double.", hResultValues.get("double") instanceof Double);
for (final String key : hResultValues.keySet()) {
final Object value = hResultValues.get(key);
@@ -167,13 +167,13 @@ public void testFRLocale() throws ValidatorException {
final Map hResultValues = results.getResultValueMap();
- assertTrue("Expecting byte result to be an instance of Byte for locale: "+locale, (hResultValues.get("byte") instanceof Byte));
- assertTrue("Expecting short result to be an instance of Short for locale: "+locale, (hResultValues.get("short") instanceof Short));
- assertTrue("Expecting integer result to be an instance of Integer for locale: "+locale, (hResultValues.get("integer") instanceof Integer));
- assertTrue("Expecting long result to be an instance of Long for locale: "+locale, (hResultValues.get("long") instanceof Long));
- assertTrue("Expecting float result to be an instance of Float for locale: "+locale, (hResultValues.get("float") instanceof Float));
- assertTrue("Expecting double result to be an instance of Double for locale: "+locale, (hResultValues.get("double") instanceof Double));
- assertTrue("Expecting date result to be an instance of Date for locale: "+locale, (hResultValues.get("date") instanceof Date));
+ assertTrue("Expecting byte result to be an instance of Byte for locale: "+locale, hResultValues.get("byte") instanceof Byte);
+ assertTrue("Expecting short result to be an instance of Short for locale: "+locale, hResultValues.get("short") instanceof Short);
+ assertTrue("Expecting integer result to be an instance of Integer for locale: "+locale, hResultValues.get("integer") instanceof Integer);
+ assertTrue("Expecting long result to be an instance of Long for locale: "+locale, hResultValues.get("long") instanceof Long);
+ assertTrue("Expecting float result to be an instance of Float for locale: "+locale, hResultValues.get("float") instanceof Float);
+ assertTrue("Expecting double result to be an instance of Double for locale: "+locale, hResultValues.get("double") instanceof Double);
+ assertTrue("Expecting date result to be an instance of Date for locale: "+locale, hResultValues.get("date") instanceof Date);
for (final String key : hResultValues.keySet()) {
final Object value = hResultValues.get(key);
diff --git a/src/test/java/org/apache/commons/validator/GenericValidatorImpl.java b/src/test/java/org/apache/commons/validator/GenericValidatorImpl.java
index fb08fbcbc..3b2256824 100644
--- a/src/test/java/org/apache/commons/validator/GenericValidatorImpl.java
+++ b/src/test/java/org/apache/commons/validator/GenericValidatorImpl.java
@@ -222,21 +222,21 @@ public static boolean validateRequiredIf(
boolean this_required = false;
if (field.isIndexed() && dependIndexed.equalsIgnoreCase("true")) {
final String key = field.getKey();
- if ((key.contains("[")) && (key.contains("]"))) {
+ if (key.contains("[") && key.contains("]")) {
final String ind = key.substring(0, key.indexOf(".") + 1);
dependProp = ind + dependProp;
}
}
final String dependVal = ValidatorUtils.getValueAsString(form, dependProp);
if (dependTest.equals(FIELD_TEST_NULL)) {
- if ((dependVal != null) && (!dependVal.isEmpty())) {
+ if (dependVal != null && !dependVal.isEmpty()) {
this_required = false;
} else {
this_required = true;
}
}
if (dependTest.equals(FIELD_TEST_NOTNULL)) {
- if ((dependVal != null) && (!dependVal.isEmpty())) {
+ if (dependVal != null && !dependVal.isEmpty()) {
this_required = true;
} else {
this_required = false;
@@ -253,7 +253,7 @@ public static boolean validateRequiredIf(
i++;
}
if (required) {
- if ((value != null) && (!value.isEmpty())) {
+ if (value != null && !value.isEmpty()) {
return true;
}
return false;
@@ -265,7 +265,7 @@ private static boolean isStringOrNull(final Object o) {
if (o == null) {
return true; // TODO this condition is not exercised by any tests currently
}
- return (o instanceof String);
+ return o instanceof String;
}
}
diff --git a/src/test/java/org/apache/commons/validator/UrlTest.java b/src/test/java/org/apache/commons/validator/UrlTest.java
index 8ea7b2106..864d24adc 100644
--- a/src/test/java/org/apache/commons/validator/UrlTest.java
+++ b/src/test/java/org/apache/commons/validator/UrlTest.java
@@ -150,11 +150,11 @@ static boolean incrementTestPartsIndex(final int[] testPartsIndex, final Object[
carry = true;
}
}
- maxIndex &= (index == (part.length - 1));
+ maxIndex &= index == part.length - 1;
}
- return (!maxIndex);
+ return !maxIndex;
}
private String testPartsIndextoString() {
diff --git a/src/test/java/org/apache/commons/validator/ValidatorTest.java b/src/test/java/org/apache/commons/validator/ValidatorTest.java
index 138d732df..981b24c3d 100644
--- a/src/test/java/org/apache/commons/validator/ValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/ValidatorTest.java
@@ -224,7 +224,7 @@ public void testManualBoolean() {
public static boolean isCapLetter(final Object bean, final Field field, final List l) {
final String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
- if ((value == null) || (value.length() != 1)) {
+ if (value == null || value.length() != 1) {
l.add("Error");
return false;
}
diff --git a/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java
index bb1fbf76f..bf163d118 100644
--- a/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/AbstractCalendarValidatorTest.java
@@ -216,17 +216,17 @@ public void testSerialization() {
protected static Calendar createCalendar(final TimeZone zone, final int date, final int time) {
final Calendar calendar = zone == null ? Calendar.getInstance()
: Calendar.getInstance(zone);
- final int year = ((date / 10000) * 10000);
- final int mth = ((date / 100) * 100) - year;
+ final int year = date / 10000 * 10000;
+ final int mth = date / 100 * 100 - year;
final int day = date - (year + mth);
- final int hour = ((time / 10000) * 10000);
- final int min = ((time / 100) * 100) - hour;
+ final int hour = time / 10000 * 10000;
+ final int min = time / 100 * 100 - hour;
final int sec = time - (hour + min);
- calendar.set(Calendar.YEAR, (year / 10000));
- calendar.set(Calendar.MONTH, ((mth / 100) - 1));
+ calendar.set(Calendar.YEAR, year / 10000);
+ calendar.set(Calendar.MONTH, mth / 100 - 1);
calendar.set(Calendar.DATE, day);
- calendar.set(Calendar.HOUR_OF_DAY, (hour / 10000));
- calendar.set(Calendar.MINUTE, (min / 100));
+ calendar.set(Calendar.HOUR_OF_DAY, hour / 10000);
+ calendar.set(Calendar.MINUTE, min / 100);
calendar.set(Calendar.SECOND, sec);
calendar.set(Calendar.MILLISECOND, 0);
return calendar;
diff --git a/src/test/java/org/apache/commons/validator/routines/CalendarValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/CalendarValidatorTest.java
index 3133af583..bb69533a8 100644
--- a/src/test/java/org/apache/commons/validator/routines/CalendarValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/CalendarValidatorTest.java
@@ -82,7 +82,7 @@ public void testCalendarValidatorMethods() {
assertFalse("isValid(B) both", CalendarValidator.getInstance().isValid("31 Dec 2005", germanPattern, Locale.GERMAN));
// Test Time Zone
- final TimeZone zone = (TimeZone.getDefault().getRawOffset() == EET.getRawOffset() ? EST : EET);
+ final TimeZone zone = TimeZone.getDefault().getRawOffset() == EET.getRawOffset() ? EST : EET;
final Date expectedZone = createCalendar(zone, 20051231, 0).getTime();
assertFalse("default/EET same ", expected.getTime() == expectedZone.getTime());
diff --git a/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java
index 7f86abce9..5822f2e06 100644
--- a/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java
@@ -42,8 +42,8 @@ public CurrencyValidatorTest(final String name) {
@Override
protected void setUp() {
- US_DOLLAR = (new DecimalFormatSymbols(Locale.US)).getCurrencySymbol();
- UK_POUND = (new DecimalFormatSymbols(Locale.UK)).getCurrencySymbol();
+ US_DOLLAR = new DecimalFormatSymbols(Locale.US).getCurrencySymbol();
+ UK_POUND = new DecimalFormatSymbols(Locale.UK).getCurrencySymbol();
}
/**
diff --git a/src/test/java/org/apache/commons/validator/routines/DateValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/DateValidatorTest.java
index 740cd072c..f8e4e87f4 100644
--- a/src/test/java/org/apache/commons/validator/routines/DateValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/DateValidatorTest.java
@@ -96,7 +96,7 @@ public void testDateValidatorMethods() {
assertFalse("isValid(B) both", DateValidator.getInstance().isValid("31 Dec 2005", germanPattern, Locale.GERMAN));
// Test Time Zone
- final TimeZone zone = (TimeZone.getDefault().getRawOffset() == EET.getRawOffset() ? EST : EET);
+ final TimeZone zone = TimeZone.getDefault().getRawOffset() == EET.getRawOffset() ? EST : EET;
final Date expectedZone = createCalendar(zone, 20051231, 0).getTime();
assertFalse("default/zone same "+zone, expected.getTime() == expectedZone.getTime());
diff --git a/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
index 85e5e86d8..2d66071ec 100644
--- a/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
@@ -389,7 +389,7 @@ public static void main(final String a[]) throws Exception {
}
br.close();
// List html entries not in TLD text list
- for(final String key : (new TreeMap<>(htmlInfo)).keySet()) {
+ for(final String key : new TreeMap<>(htmlInfo).keySet()) {
if (!ianaTlds.contains(key)) {
if (isNotInRootZone(key)) {
System.out.println("INFO: HTML entry not yet in root zone: "+key);
diff --git a/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
index 6c8071e12..b0ebd230e 100644
--- a/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
@@ -217,9 +217,9 @@ public void testEmailWithSpaces() {
@Test
public void testEmailWithControlChars() {
for (char c = 0; c < 32; c++) {
- assertFalse("Test control char " + ((int)c), validator.isValid("foo" + c + "bar@domain.com"));
+ assertFalse("Test control char " + (int)c, validator.isValid("foo" + c + "bar@domain.com"));
}
- assertFalse("Test control char 127", validator.isValid("foo" + ((char)127) + "bar@domain.com"));
+ assertFalse("Test control char 127", validator.isValid("foo" + (char)127 + "bar@domain.com"));
}
/**
diff --git a/src/test/java/org/apache/commons/validator/routines/FloatValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/FloatValidatorTest.java
index 6332e18a9..e7826cd0b 100644
--- a/src/test/java/org/apache/commons/validator/routines/FloatValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/FloatValidatorTest.java
@@ -124,7 +124,7 @@ public void testFloatSmallestValues() {
assertEquals("Smallest -ve", smallestNegative, FloatValidator.getInstance().validate(strSmallestNegative, pattern));
// Validate Too Small +ve
- final Double tooSmallPositive = Double.valueOf(((double)Float.MIN_VALUE / (double)10));
+ final Double tooSmallPositive = Double.valueOf((double)Float.MIN_VALUE / (double)10);
final String strTooSmallPositive = fmt.format(tooSmallPositive);
assertFalse("Too small +ve", FloatValidator.getInstance().isValid(strTooSmallPositive, pattern));
diff --git a/src/test/java/org/apache/commons/validator/routines/IBANValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/IBANValidatorTest.java
index 6f0823255..228fdb646 100644
--- a/src/test/java/org/apache/commons/validator/routines/IBANValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/IBANValidatorTest.java
@@ -222,7 +222,7 @@ private static void printEntry(final String ccode, final String length, final St
"AX5542345670000081", // FI other
"FO6264600001631634",
"FR1420041010050500013M02606",
- // FR 'other'
+ // FR 'other'
"BL6820041010050500013M02606", // FR other
"GF4120041010050500013M02606", // FR other
"GP1120041010050500013M02606", // FR other
@@ -236,7 +236,7 @@ private static void printEntry(final String ccode, final String length, final St
"WF9120041010050500013M02606", // FR other
"YT3120041010050500013M02606", // FR other
"GB29NWBK60161331926819",
- // GB 'other'
+ // GB 'other'
// "IM...", // GB other
// "JE...", // GB other
// "GG...", // GB other
diff --git a/src/test/java/org/apache/commons/validator/routines/RegexValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/RegexValidatorTest.java
index c9e917c4a..a2cf09a1e 100644
--- a/src/test/java/org/apache/commons/validator/routines/RegexValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/RegexValidatorTest.java
@@ -128,7 +128,7 @@ public void testMissingRegex() {
// Multiple Regular Expression - Zero Length array
try {
- new RegexValidator(new String[0]);
+ new RegexValidator();
fail("Zero Length Array - expected IllegalArgumentException");
} catch (final IllegalArgumentException e) {
assertEquals("Zero Length Array", "Regular expressions are missing", e.getMessage());
@@ -152,7 +152,7 @@ public void testMissingRegex() {
assertEquals("Array has Zero Length", "Regular expression[0] is missing", e.getMessage());
}
}
-
+
/**
* Test with multiple regular expressions (case in-sensitive).
*/
@@ -270,8 +270,8 @@ public void testSingle() {
checkArray("Sensitive match() invalid", null, sensitive.match("AB-de-1"));
checkArray("Insensitive match() valid", new String[] {"AB", "de", "1"}, insensitive.match("AB-de-1"));
checkArray("Insensitive match() invalid", null, insensitive.match("ABd-de-1"));
- assertEquals("validate one", "ABC", (new RegexValidator("^([A-Z]*)$")).validate("ABC"));
- checkArray("match one", new String[] {"ABC"}, (new RegexValidator("^([A-Z]*)$")).match("ABC"));
+ assertEquals("validate one", "ABC", new RegexValidator("^([A-Z]*)$").validate("ABC"));
+ checkArray("match one", new String[] {"ABC"}, new RegexValidator("^([A-Z]*)$").match("ABC"));
}
/**
@@ -281,7 +281,7 @@ public void testToString() {
final RegexValidator single = new RegexValidator(REGEX);
assertEquals("Single", "RegexValidator{" + REGEX + "}", single.toString());
- final RegexValidator multiple = new RegexValidator(new String[] {REGEX, REGEX});
+ final RegexValidator multiple = new RegexValidator(REGEX, REGEX);
assertEquals("Multiple", "RegexValidator{" + REGEX + "," + REGEX + "}", multiple.toString());
}
diff --git a/src/test/java/org/apache/commons/validator/routines/TimeValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/TimeValidatorTest.java
index 60d4b25a1..eec1506f7 100644
--- a/src/test/java/org/apache/commons/validator/routines/TimeValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/TimeValidatorTest.java
@@ -309,14 +309,14 @@ public void testCompare() {
protected static Calendar createTime(final TimeZone zone, final int time, final int millisecond) {
final Calendar calendar = zone == null ? Calendar.getInstance()
: Calendar.getInstance(zone);
- final int hour = ((time / 10000) * 10000);
- final int min = ((time / 100) * 100) - hour;
+ final int hour = time / 10000 * 10000;
+ final int min = time / 100 * 100 - hour;
final int sec = time - (hour + min);
calendar.set(Calendar.YEAR, 1970);
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DATE, 1);
- calendar.set(Calendar.HOUR_OF_DAY, (hour / 10000));
- calendar.set(Calendar.MINUTE, (min / 100));
+ calendar.set(Calendar.HOUR_OF_DAY, hour / 10000);
+ calendar.set(Calendar.MINUTE, min / 100);
calendar.set(Calendar.SECOND, sec);
calendar.set(Calendar.MILLISECOND, millisecond);
return calendar;
diff --git a/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
index 1e4f3065a..8fc0fd815 100644
--- a/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
@@ -170,7 +170,7 @@ public void testValidator235() {
@Test
public void testValidator248() {
- final RegexValidator regex = new RegexValidator(new String[] {"localhost", ".*\\.my-testing"});
+ final RegexValidator regex = new RegexValidator("localhost", ".*\\.my-testing");
UrlValidator validator = new UrlValidator(regex, 0);
assertTrue("localhost URL should validate",
@@ -393,7 +393,7 @@ static boolean incrementTestPartsIndex(final int[] testPartsIndex, final Object[
for (int testPartsIndexIndex = testPartsIndex.length - 1; testPartsIndexIndex >= 0; --testPartsIndexIndex) {
int index = testPartsIndex[testPartsIndexIndex];
final ResultPair[] part = (ResultPair[]) testParts[testPartsIndexIndex];
- maxIndex &= (index == (part.length - 1));
+ maxIndex &= index == part.length - 1;
if (carry) {
if (index < part.length - 1) {
index++;
@@ -407,7 +407,7 @@ static boolean incrementTestPartsIndex(final int[] testPartsIndex, final Object[
}
- return (!maxIndex);
+ return !maxIndex;
}
private String testPartsIndextoString() {