Skip to content

Commit

Permalink
Use Objects.requireNonNull()
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 26, 2024
1 parent 54131ff commit f195e60
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/org/apache/commons/validator/FormSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -222,19 +223,18 @@ private Log getLog() {
* 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;
Expand Down

0 comments on commit f195e60

Please sign in to comment.