Package org.bonitasoft.engine.commons
Class NullCheckingUtil
- java.lang.Object
-
- org.bonitasoft.engine.commons.NullCheckingUtil
-
public class NullCheckingUtil extends java.lang.Object- Author:
- Elias Ricken de Medeiros
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNullCheckingUtil.NullCheckResultRepresents null value returned byfindNull(Object...).
-
Constructor Summary
Constructors Constructor Description NullCheckingUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbadStateIfNull(java.lang.Object valueToCheck, java.lang.String msg)This method throw an IllegalStateException if the given parameter is nullstatic voidbadStateIfTrue(boolean valueToCheck, java.lang.String msg)This method throw an IllegalStateException if the given parameter is truestatic voidcheckArgsNotNull(java.lang.Object... params)Check that the given parameters are not null.static NullCheckingUtil.NullCheckResultfindNull(java.lang.Object... params)Find null parameters in the given list.static java.lang.StackTraceElementgetCaller(int offset)Return the StackTraceElement at the given offset from this method invocation.
-
-
-
Method Detail
-
checkArgsNotNull
public static void checkArgsNotNull(java.lang.Object... params)
Check that the given parameters are not null. This method should only be used to check that some parameters given to a given method are not null. The exception message tries its best to produce a helpful message by scanning the stack trace.- Parameters:
params- the parameters to check- Throws:
java.lang.IllegalArgumentException- if at least one of the parameters is null
-
findNull
public static NullCheckingUtil.NullCheckResult findNull(java.lang.Object... params)
Find null parameters in the given list. This method returns aNullCheckingUtil.NullCheckResult.- Parameters:
params- the parameters to check- Returns:
- a
NullCheckingUtil.NullCheckResultrepresenting null parameters. - See Also:
NullCheckingUtil.NullCheckResult
-
getCaller
public static java.lang.StackTraceElement getCaller(int offset)
Return the StackTraceElement at the given offset from this method invocation.- Parameters:
offset-- Returns:
- a StackTraceElement
-
badStateIfNull
public static void badStateIfNull(java.lang.Object valueToCheck, java.lang.String msg)This method throw an IllegalStateException if the given parameter is null- Parameters:
valueToCheck- the value to checkmsg- the message for the thrown exception- See Also:
IllegalStateException
-
badStateIfTrue
public static void badStateIfTrue(boolean valueToCheck, java.lang.String msg)This method throw an IllegalStateException if the given parameter is true- Parameters:
valueToCheck- the value to checkmsg- the message for the thrown exception- See Also:
IllegalStateException
-
-