001         package com.croftsoft.core.lang;
002    
003         /*********************************************************************
004         * Thrown to indicate that a method has been passed a null argument.
005         *
006         * <p>
007         * The static convenience method <i>check()</i> is a useful shorthand
008         * notation for checking whether object constructor method arguments
009         * are null:
010         * <pre><code>
011         * public  Book ( String  title )
012         * {
013         *   NullArgumentException.check ( this.title = title, "null title" );
014         * }
015         * </code></pre>
016         * </p>
017         *
018         * @version
019         *   $Date: 2008/02/10 22:53:21 $
020         * @since
021         *   2001-02-16
022         * @author
023         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
024         *********************************************************************/
025    
026         public final class  NullArgumentException
027           extends IllegalArgumentException
028         //////////////////////////////////////////////////////////////////////
029         //////////////////////////////////////////////////////////////////////
030         {
031           
032         private static final long  serialVersionUID = 0L;
033    
034         //////////////////////////////////////////////////////////////////////
035         // public static methods
036         //////////////////////////////////////////////////////////////////////
037         
038         /*********************************************************************
039         * Checks whether the argument is null.
040         *
041         * @throws NullArgumentException
042         * 
043         *   If the argument is null.
044         *********************************************************************/
045         public static void  check ( Object  argument )
046         //////////////////////////////////////////////////////////////////////
047         {
048           if ( argument == null )
049           {
050             throw new NullArgumentException ( );
051           }
052         }
053    
054         /*********************************************************************
055         * Checks whether the argument is null.
056         *
057         * @param  detailMessage
058         * 
059         *   The detail message provided if a NullArgumentExcepton is created.
060         *   
061         * @throws NullArgumentException
062         * 
063         *   If the argument is null.
064         *********************************************************************/
065         public static void  check (
066           Object  argument,
067           String  detailMessage )
068         //////////////////////////////////////////////////////////////////////
069         {
070           if ( argument == null )
071           {
072             throw new NullArgumentException ( detailMessage );
073           }
074         }
075         
076         public static void  checkArgs ( Object...  args )
077         //////////////////////////////////////////////////////////////////////
078         {
079           for ( Object  argument : args )
080           {
081             check ( argument );
082           }
083         }
084    
085         //////////////////////////////////////////////////////////////////////
086         // public constructor methods
087         //////////////////////////////////////////////////////////////////////
088    
089         public  NullArgumentException ( )
090         //////////////////////////////////////////////////////////////////////
091         {
092           // empty
093         }
094    
095         public  NullArgumentException ( String  detailMessage )
096         //////////////////////////////////////////////////////////////////////
097         {
098           super ( detailMessage );
099         }
100    
101         //////////////////////////////////////////////////////////////////////
102         //////////////////////////////////////////////////////////////////////
103         }