Coverage Report - ca.uhn.hl7v2.hoh.util.Validate
 
Classes in this File Line Coverage Branch Coverage Complexity
Validate
42%
6/14
25%
4/16
3.667
 
 1  
 package ca.uhn.hl7v2.hoh.util;
 2  
 
 3  
 /**
 4  
  * Utility class for parameter validation
 5  
  * 
 6  
  */
 7  5
 public abstract class Validate {
 8  
 
 9  
         /**
 10  
          * @throws IllegalArgumentException
 11  
          *             If theObject is null
 12  
          */
 13  
         public static void notNull(Object theObject, String theName) {
 14  65
                 assert theName != null;
 15  
 
 16  65
                 if (theObject == null) {
 17  0
                         throw new IllegalArgumentException(theName + " can not be null");
 18  
                 }
 19  65
         }
 20  
 
 21  
         /**
 22  
          * @throws IllegalArgumentException
 23  
          *             If theObject is null or contains no non-whitespace characters
 24  
          */
 25  
         public static void notBlank(String theObject, String theName) {
 26  0
                 assert theName != null;
 27  
 
 28  0
                 if (theObject == null) {
 29  0
                         throw new IllegalArgumentException(theName + " can not be null");
 30  
                 }
 31  
 
 32  0
                 if (theObject.trim().length() == 0) {
 33  0
                         throw new IllegalArgumentException(theName + " can not be empty");
 34  
                 }
 35  0
         }
 36  
 
 37  
         public static void propertySet(Object theValue, String theName) {
 38  60
                 if (theValue == null) {
 39  0
                         throw new IllegalStateException("Property \"" + theName + "\" is not set");
 40  
                 }
 41  60
         }
 42  
 
 43  
 }