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 2021/02/07 15:34:35 UTC
[commons-lang] 01/08: No need to nest.
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-lang.git
commit ac6ebf4e1c506deea6c2993e111d93f3cac65e44
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Feb 7 10:15:29 2021 -0500
No need to nest.
---
.../org/apache/commons/lang3/function/Objects.java | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/function/Objects.java b/src/main/java/org/apache/commons/lang3/function/Objects.java
index 02f7ddb..b2310f6 100755
--- a/src/main/java/org/apache/commons/lang3/function/Objects.java
+++ b/src/main/java/org/apache/commons/lang3/function/Objects.java
@@ -72,9 +72,8 @@ public class Objects {
public static <O> @Nonnull O requireNonNull(@Nullable O value) throws NullPointerException {
if (value == null) {
throw new NullPointerException("The value must not be null.");
- } else {
- return value;
}
+ return value;
}
/**
@@ -92,12 +91,10 @@ public class Objects {
if (value == null) {
if (defaultValue == null) {
throw new NullPointerException("The default value must not be null.");
- } else {
- return defaultValue;
}
- } else {
- return value;
+ return defaultValue;
}
+ return value;
}
/**
@@ -115,9 +112,8 @@ public class Objects {
public static <O> @Nonnull O requireNonNull(@Nullable O value, @Nonnull String msg) throws NullPointerException {
if (value == null) {
throw new NullPointerException(msg);
- } else {
- return value;
}
+ return value;
}
/**
@@ -135,9 +131,8 @@ public class Objects {
public static <O> @Nonnull O requireNonNull(@Nullable O value, @Nonnull Supplier<String> msgSupplier) throws NullPointerException {
if (value == null) {
throw new NullPointerException(msgSupplier.get());
- } else {
- return value;
}
+ return value;
}
/** Checks, whether the given object is non-null. If so, returns the non-null
@@ -169,8 +164,7 @@ public class Objects {
throw Failable.rethrow(t);
}
return requireNonNull(o, "The supplier must not return null.");
- } else {
- return value;
}
+ return value;
}
}