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 2024/05/25 19:18:08 UTC
(commons-validator) 02/04: Use final
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
commit cdf0ac1eb4d6555298b9af90436143f44fc25777
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat May 25 15:04:38 2024 -0400
Use final
---
.../routines/checkdigit/CASNumberCheckDigit.java | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/main/java/org/apache/commons/validator/routines/checkdigit/CASNumberCheckDigit.java b/src/main/java/org/apache/commons/validator/routines/checkdigit/CASNumberCheckDigit.java
index 8fefce7c..f73807f3 100644
--- a/src/main/java/org/apache/commons/validator/routines/checkdigit/CASNumberCheckDigit.java
+++ b/src/main/java/org/apache/commons/validator/routines/checkdigit/CASNumberCheckDigit.java
@@ -114,7 +114,7 @@ public final class CASNumberCheckDigit extends ModulusCheckDigit {
if (GenericValidator.isBlankOrNull(code)) {
throw new CheckDigitException("Code is missing");
}
- int modulusResult = INSTANCE.calculateModulus(code, false);
+ final int modulusResult = INSTANCE.calculateModulus(code, false);
return toCheckDigit(modulusResult);
}
@@ -126,15 +126,14 @@ public final class CASNumberCheckDigit extends ModulusCheckDigit {
if (GenericValidator.isBlankOrNull(code)) {
return false;
}
- Object cde = REGEX_VALIDATOR.validate(code);
- if (cde instanceof String) {
- try {
- final int modulusResult = INSTANCE.calculateModulus((String) cde, true);
- return modulusResult == Character.getNumericValue(code.charAt(code.length() - 1));
- } catch (final CheckDigitException ex) {
- return false;
- }
- } else {
+ final Object cde = REGEX_VALIDATOR.validate(code);
+ if (!(cde instanceof String)) {
+ return false;
+ }
+ try {
+ final int modulusResult = INSTANCE.calculateModulus((String) cde, true);
+ return modulusResult == Character.getNumericValue(code.charAt(code.length() - 1));
+ } catch (final CheckDigitException ex) {
return false;
}
}