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 anullargument 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 ofNullPointerExceptionfrom within Commons-Math is construed to be a bug.Note: from 4.0 onwards, this class extends
NullPointerExceptioninstead 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 voidcheck(Object o)Checks that an object is not null.static voidcheck(Object o, Localizable pattern, Object... args)Checks that an object is not null.ExceptionContextgetContext()Gets a reference to the "rich context" data structure that allows to customize error messages and store key, value pairs in exceptions.StringgetLocalizedMessage()StringgetMessage()-
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:
getContextin interfaceExceptionContextProvider- Returns:
- a reference to the exception context.
- Since:
- 4.0
-
getMessage
public String getMessage()
- Overrides:
getMessagein classThrowable
-
getLocalizedMessage
public String getLocalizedMessage()
- Overrides:
getLocalizedMessagein 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- ifoisnull.
-
check
public static void check(Object o)
Checks that an object is not null.- Parameters:
o- Object to be checked.- Throws:
NullArgumentException- ifoisnull.
-
-