net.sf.mmm.util.nls.api
Class NlsNullPointerException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
net.sf.mmm.util.nls.api.AbstractNlsRuntimeException
net.sf.mmm.util.nls.api.NlsRuntimeException
net.sf.mmm.util.nls.api.NlsNullPointerException
- All Implemented Interfaces:
- Serializable, NlsObject, NlsThrowable
public class NlsNullPointerException
- extends NlsRuntimeException
A NlsNullPointerException is analog to an
NullPointerException but with native language support.
- Since:
- 1.0.2
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
- See Also:
- Serialized Form
| Fields inherited from interface net.sf.mmm.util.nls.api.NlsObject |
KEY_ANNOTATION, KEY_ARGUMENT, KEY_CAPACITY, KEY_DEFAULT, KEY_DIRECTORY, KEY_ERROR, KEY_FILE, KEY_FUNCTION, KEY_ID, KEY_KEY, KEY_LOCATION, KEY_MAX, KEY_MIN, KEY_MODE, KEY_NAME, KEY_OBJECT, KEY_OPERAND, KEY_OPERATION, KEY_OPTION, KEY_PATH, KEY_PROPERTY, KEY_QUERY, KEY_RESOURCE, KEY_SIZE, KEY_SOURCE, KEY_TARGET_TYPE, KEY_TITLE, KEY_TYPE, KEY_URI, KEY_VALUE |
|
Method Summary |
static
|
checkNotNull(Class<O> type,
O object)
This method checks if the given object is null. |
static void |
checkNotNull(String objectName,
Object object)
This method checks if the given object is null. |
| Methods inherited from class net.sf.mmm.util.nls.api.AbstractNlsRuntimeException |
createUuid, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getMessage, getNlsMessage, getUuid, printStackTrace, printStackTrace, printStackTrace, printStackTrace, toNlsMessage |
serialVersionUID
private static final long serialVersionUID
- UID for serialization.
- See Also:
- Constant Field Values
NlsNullPointerException
public NlsNullPointerException(String argument)
- The constructor.
- Parameters:
argument - is the argument that is illegal. May be null.
NlsNullPointerException
public NlsNullPointerException(String argument,
Throwable nested)
- The constructor.
- Parameters:
argument - is the argument that is illegal. May be null.nested - is the cause of this exception.
checkNotNull
public static <O> void checkNotNull(Class<O> type,
O object)
throws NlsNullPointerException
- This method checks if the given
object is null.
ATTENTION:
This method is only intended to be used for specific types. It then not
only saves you from a single if-statement, but also defines a
common pattern that is refactoring-safe.
Anyhow you should never use this method with generic Classes for
type such as Object, String, Integer,
etc.
Here is an example:
public void myMethod(MySpecificBusinessObject businessObject, String someParameter) {
NlsNullPointerException.checkNotNull(MySpecificBusinessObject.class, businessObject);
NlsNullPointerException.checkNotNull("someParameter", someParameter);
doTheWork();
}
- Type Parameters:
O - is the generic type of the object.- Parameters:
type - is the class reflecting the object. Its
simple name will be used in the
exception-message if object is null.object - is the object that is checked and should NOT be
null.
- Throws:
NlsNullPointerException - if the given object is
null.
checkNotNull
public static void checkNotNull(String objectName,
Object object)
throws NlsNullPointerException
- This method checks if the given
object is null.
Look at the following example:
NlsNullPointerException.checkNotNull("someParameter", someParameter);
This is equivalent to this code:
if (someParameter == null) {
throw new NlsNullPointerException("someParameter");
}
- Parameters:
objectName - is the (argument-)name of the given object.object - is the object that is checked and should NOT be
null.
- Throws:
NlsNullPointerException - if the given object is
null.- Since:
- 2.0.0
Copyright © 2001-2010 mmm-Team. All Rights Reserved.