Class NullArgumentException

  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended byjava.lang.IllegalArgumentException
                  extended byorg.apache.commons.lang.NullArgumentException
All Implemented Interfaces:

public class NullArgumentException
extends java.lang.IllegalArgumentException

Thrown to indicate that an argument was null and should not have been. This exception supplements the standard IllegalArgumentException by providing a more semantically rich description of the problem.

NullArgumentException represents the case where a method takes in a parameter that must not be null. Some coding standards would use NullPointerException for this case, others will use IllegalArgumentException. Thus this exception would be used in place of IllegalArgumentException, yet it still extends it.

 public void foo(String str) {
   if (str == null) {
     throw new NullArgumentException("str");
   // do something with the string

$Id: 437554 2006-08-28 06:21:41Z bayard $
Matthew Hawthorne, Stephen Colebourne
See Also:
Serialized Form

Constructor Summary
NullArgumentException(java.lang.String argName)
          Instantiates with the given argument name.
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public NullArgumentException(java.lang.String argName)

Instantiates with the given argument name.

argName - the name of the argument that was null.

Copyright 2001-2008 The Apache Software Foundation. All Rights Reserved.