You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2014/03/27 06:37:54 UTC
svn commit: r1582194 -
/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Assert.java
Author: ggregory
Date: Thu Mar 27 05:37:54 2014
New Revision: 1582194
URL: http://svn.apache.org/r1582194
Log:
The code and Javadoc do not match. Make the behavior like the same Java 7 Objects API.
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Assert.java
Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Assert.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Assert.java?rev=1582194&r1=1582193&r2=1582194&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Assert.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Assert.java Thu Mar 27 05:37:54 2014
@@ -27,7 +27,7 @@ public final class Assert {
* Throws a {@code NullPointerException} if the specified parameter is
* {@code null}, otherwise returns the specified parameter.
* <p>
- * On Java 7, just use Objects#requireNonNull()
+ * On Java 7, just use {@code Objects.requireNonNull(T, String)}
* </p>
* <p>
* Usage:
@@ -36,27 +36,27 @@ public final class Assert {
* // earlier you would write this:
* public SomeConstructor(Object param) {
* if (param == null) {
- * throw new NullPointerException(name + " is null");
+ * throw new NullPointerException("param");
* }
* this.field = param;
* }
*
* // now you can do the same in one line:
* public SomeConstructor(Object param) {
- * this.field = Assert.requireNonNull(param);
+ * this.field = Assert.requireNonNull("param");
* }
* </pre>
*
* @param <T> the type of the parameter to check and return
- * @param checkMe the parameter to check
- * @param name name of the parameter to use in the error message if
+ * @param object the parameter to check
+ * @param message name of the parameter to use in the error message if
* {@code null}
* @return the specified parameter
*/
- public static <T> T requireNonNull(final T checkMe, final String name) {
- if (checkMe == null) {
- throw new NullPointerException(name + " is null");
+ public static <T> T requireNonNull(final T object, final String message) {
+ if (object == null) {
+ throw new NullPointerException(message);
}
- return checkMe;
+ return object;
}
}