|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.logging.log4j.core.helpers.Assert
public final class Assert
Utility class providing common validation logic.
Method Summary | ||
---|---|---|
static
|
isNotNull(T checkMe,
String name)
Throws a NullPointerException if the specified parameter is
null , otherwise returns the specified parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> T isNotNull(T checkMe, String name)
NullPointerException
if the specified parameter is
null
, otherwise returns the specified parameter.
Usage:
// earlier you would write this: public SomeConstructor(Object param) { if (param == null) { throw new NullPointerException(name + " is null"); } this.field = param; } // now you can do the same in one line: public SomeConstructor(Object param) { this.field = Assert.isNotNull(param); }
T
- the type of the parameter to check and returncheckMe
- the parameter to checkname
- name of the parameter to use in the error message if
null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1999-2013 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.