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 f195e605 Use Objects.requireNonNull()
f195e605 is described below
commit f195e6050a535a8eda192cebb4892fdd19f5813a
Author: Gary D. Gregory <[email protected]>
AuthorDate: Thu Dec 26 14:24:46 2024 -0500
Use Objects.requireNonNull()
---
src/main/java/org/apache/commons/validator/FormSet.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/commons/validator/FormSet.java
b/src/main/java/org/apache/commons/validator/FormSet.java
index 7c3907ec..51e1a252 100644
--- a/src/main/java/org/apache/commons/validator/FormSet.java
+++ b/src/main/java/org/apache/commons/validator/FormSet.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -222,19 +223,18 @@ public class FormSet implements Serializable {
* definition (not sure about this)
*/
protected int getType() {
+ final String myLanguage = getLanguage();
+ final String myCountry = getCountry();
if (getVariant() != null) {
- if (getLanguage() == null || getCountry() == null) {
- throw new NullPointerException("When variant is specified,
country and language must be specified.");
- }
+ Objects.requireNonNull(myLanguage, "When variant is specified,
country and language must be specified.");
+ Objects.requireNonNull(myCountry, "When variant is specified,
country and language must be specified.");
return VARIANT_FORMSET;
}
- if (getCountry() != null) {
- if (getLanguage() == null) {
- throw new NullPointerException("When country is specified,
language must be specified.");
- }
+ if (myCountry != null) {
+ Objects.requireNonNull(myLanguage, "When country is specified,
language must be specified.");
return COUNTRY_FORMSET;
}
- if (getLanguage() != null) {
+ if (myLanguage != null) {
return LANGUAGE_FORMSET;
}
return GLOBAL_FORMSET;