Class NullArgumentException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- java.lang.NullPointerException
-
- org.apache.commons.math4.legacy.exception.NullArgumentException
-
- All Implemented Interfaces:
Serializable
,ExceptionContextProvider
public class NullArgumentException extends NullPointerException implements ExceptionContextProvider
All conditions checks that fail due to anull
argument must throw this exception. This class is meant to signal a precondition violation ("null is an illegal argument") and so does not extend the standardNullPointerException
. Propagation ofNullPointerException
from within Commons-Math is construed to be a bug.Note: from 4.0 onwards, this class extends
NullPointerException
instead ofMathIllegalArgumentException
.- Since:
- 2.2
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NullArgumentException()
Default constructor.NullArgumentException(Localizable pattern, Object... arguments)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
check(Object o)
Checks that an object is not null.static void
check(Object o, Localizable pattern, Object... args)
Checks that an object is not null.ExceptionContext
getContext()
Gets a reference to the "rich context" data structure that allows to customize error messages and store key, value pairs in exceptions.String
getLocalizedMessage()
String
getMessage()
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
NullArgumentException
public NullArgumentException()
Default constructor.
-
NullArgumentException
public NullArgumentException(Localizable pattern, Object... arguments)
- Parameters:
pattern
- Message pattern providing the specific context of the error.arguments
- Values for replacing the placeholders inpattern
.
-
-
Method Detail
-
getContext
public ExceptionContext getContext()
Gets a reference to the "rich context" data structure that allows to customize error messages and store key, value pairs in exceptions.- Specified by:
getContext
in interfaceExceptionContextProvider
- Returns:
- a reference to the exception context.
- Since:
- 4.0
-
getMessage
public String getMessage()
- Overrides:
getMessage
in classThrowable
-
getLocalizedMessage
public String getLocalizedMessage()
- Overrides:
getLocalizedMessage
in classThrowable
-
check
public static void check(Object o, Localizable pattern, Object... args)
Checks that an object is not null.- Parameters:
o
- Object to be checked.pattern
- Message pattern.args
- Arguments to replace the placeholders inpattern
.- Throws:
NullArgumentException
- ifo
isnull
.
-
check
public static void check(Object o)
Checks that an object is not null.- Parameters:
o
- Object to be checked.- Throws:
NullArgumentException
- ifo
isnull
.
-
-