You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/06/10 18:16:30 UTC
[commons-validator] branch master updated: Use else-if instead of nested else block
This is an automated email from the ASF dual-hosted git repository.
ggregory 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 26f318a7 Use else-if instead of nested else block
26f318a7 is described below
commit 26f318a7fa79138b1a28a4df0cf60d61bb72ddd7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 10 14:16:25 2022 -0400
Use else-if instead of nested else block
---
.../apache/commons/validator/ValidatorAction.java | 24 ++++++++++------------
.../commons/validator/ValidatorResources.java | 8 +++-----
.../java/org/apache/commons/validator/UrlTest.java | 4 +---
.../validator/routines/UrlValidatorTest.java | 4 +---
4 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/src/main/java/org/apache/commons/validator/ValidatorAction.java b/src/main/java/org/apache/commons/validator/ValidatorAction.java
index 4ce15650..f560be39 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorAction.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorAction.java
@@ -687,19 +687,17 @@ public class ValidatorAction implements Serializable {
if (Modifier.isStatic(this.validationMethod.getModifiers())) {
this.instance = null;
- } else {
- if (this.instance == null) {
- try {
- this.instance = this.validationClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- String msg1 =
- "Couldn't create instance of "
- + this.classname
- + ". "
- + e.getMessage();
-
- throw new ValidatorException(msg1);
- }
+ } else if (this.instance == null) {
+ try {
+ this.instance = this.validationClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ String msg1 =
+ "Couldn't create instance of "
+ + this.classname
+ + ". "
+ + e.getMessage();
+
+ throw new ValidatorException(msg1);
}
}
diff --git a/src/main/java/org/apache/commons/validator/ValidatorResources.java b/src/main/java/org/apache/commons/validator/ValidatorResources.java
index cde2574f..06449f67 100644
--- a/src/main/java/org/apache/commons/validator/ValidatorResources.java
+++ b/src/main/java/org/apache/commons/validator/ValidatorResources.java
@@ -495,11 +495,9 @@ public class ValidatorResources implements Serializable {
getLog().warn("Form '" + formKey + "' not found for locale '" +
localeKey + "'");
}
- } else {
- if (getLog().isDebugEnabled()) {
- getLog().debug("Form '" + formKey + "' found in formset '" +
- key + "' for locale '" + localeKey + "'");
- }
+ } else if (getLog().isDebugEnabled()) {
+ getLog().debug("Form '" + formKey + "' found in formset '" +
+ key + "' for locale '" + localeKey + "'");
}
return form;
diff --git a/src/test/java/org/apache/commons/validator/UrlTest.java b/src/test/java/org/apache/commons/validator/UrlTest.java
index deb005bc..3a1f7ca1 100644
--- a/src/test/java/org/apache/commons/validator/UrlTest.java
+++ b/src/test/java/org/apache/commons/validator/UrlTest.java
@@ -106,13 +106,11 @@ protected void setUp() {
if (printStatus) {
if (printIndex) {
System.out.print(testPartsIndextoString());
- } else {
- if (result == expected) {
+ } else if (result == expected) {
System.out.print('.');
} else {
System.out.print('X');
}
- }
printed++;
if (printed == statusPerLine) {
System.out.println();
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 55794568..8df0f949 100644
--- a/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java
@@ -110,13 +110,11 @@ public class UrlValidatorTest {
if (printStatus) {
if (printIndex) {
System.out.print(testPartsIndextoString());
- } else {
- if (result == expected) {
+ } else if (result == expected) {
System.out.print('.');
} else {
System.out.print('X');
}
- }
printed++;
if (printed == statusPerLine) {
System.out.println();