Class NullArgumentException

  • All Implemented Interfaces:
    java.io.Serializable

    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
     }
     
    Since:
    2.0
    Version:
    $Id: NullArgumentException.java 905636 2010-02-02 14:03:32Z niallp $
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long serialVersionUID
      Required for serialization support.
    • Constructor Summary

      Constructors 
      Constructor Description
      NullArgumentException​(java.lang.String argName)
      Instantiates with the given argument name.
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Required for serialization support.
        See Also:
        Serializable, Constant Field Values
    • Constructor Detail

      • NullArgumentException

        public NullArgumentException​(java.lang.String argName)

        Instantiates with the given argument name.

        Parameters:
        argName - the name of the argument that was null.