Coverage Report - de.smartics.util.lang.NullArgumentException
 
Classes in this File Line Coverage Branch Coverage Complexity
NullArgumentException
0%
0/6
0%
0/4
1,667
 
 1  
 /*
 2  
  * Copyright 2011-2013 smartics, Kronseder & Reiner GmbH
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package de.smartics.util.lang;
 17  
 
 18  
 /**
 19  
  * Signals that a given argument is <code>null</code> where is must no be
 20  
  * <code>null</code>.
 21  
  * <p>
 22  
  * Due to Java conventions the exception does not derive from
 23  
  * {@link IllegalArgumentException} as one might expect.
 24  
  * </p>
 25  
  * <blockquote>If a caller passes <code>null</code> in some parameter for which
 26  
  * null values are prohibited, convention dictates that
 27  
  * {@link NullPointerException} be thrown rather than
 28  
  * {@link IllegalArgumentException}.</blockquote>
 29  
  * <p>
 30  
  * Effective Java - Second Edition, p 248
 31  
  * </p>
 32  
  */
 33  
 public class NullArgumentException extends NullPointerException
 34  
 {
 35  
   // ********************************* Fields *********************************
 36  
 
 37  
   // --- constants ------------------------------------------------------------
 38  
 
 39  
   /**
 40  
    * The class version identifier.
 41  
    * <p>
 42  
    * The value of this constant is {@value}.
 43  
    * </p>
 44  
    */
 45  
   private static final long serialVersionUID = 1L;
 46  
 
 47  
   // --- members --------------------------------------------------------------
 48  
 
 49  
   // ****************************** Initializer *******************************
 50  
 
 51  
   // ****************************** Constructors ******************************
 52  
 
 53  
   /**
 54  
    * Convenience constructor if no argument name needs to be provided. This
 55  
    * constructor is not recommended since the exception's message is less
 56  
    * verbose.
 57  
    */
 58  
   public NullArgumentException()
 59  
   {
 60  0
     this(null);
 61  0
   }
 62  
 
 63  
   /**
 64  
    * Convenience constructor.
 65  
    *
 66  
    * @param argName the name of the argument that was <code>null</code>.
 67  
    */
 68  
   public NullArgumentException(final String argName)
 69  
   {
 70  0
     this(argName, null);
 71  0
   }
 72  
 
 73  
   /**
 74  
    * Default constructor.
 75  
    *
 76  
    * @param argName the name of the argument that was <code>null</code>.
 77  
    * @param message an optional additional message to provide information about
 78  
    *          the context of the argument.
 79  
    * @see java.lang.IllegalArgumentException#IllegalArgumentException(java.lang.String)
 80  
    */
 81  
   public NullArgumentException(final String argName, final String message)
 82  
   {
 83  0
     super((argName == null ? "Argument" : argName) + " must not be 'null'"
 84  
           + (message != null ? ": " + message : "."));
 85  0
   }
 86  
 
 87  
   // ****************************** Inner Classes *****************************
 88  
 
 89  
   // ********************************* Methods ********************************
 90  
 
 91  
   // --- init -----------------------------------------------------------------
 92  
 
 93  
   // --- get&set --------------------------------------------------------------
 94  
 
 95  
   // --- business -------------------------------------------------------------
 96  
 
 97  
   // --- object basics --------------------------------------------------------
 98  
 
 99  
 }