001package ca.uhn.hl7v2.hoh.util;
002
003/**
004 * Utility class for parameter validation
005 * 
006 */
007public abstract class Validate {
008
009        /**
010         * @throws IllegalArgumentException
011         *             If theObject is null
012         */
013        public static void notNull(Object theObject, String theName) {
014                assert theName != null;
015
016                if (theObject == null) {
017                        throw new IllegalArgumentException(theName + " can not be null");
018                }
019        }
020
021        /**
022         * @throws IllegalArgumentException
023         *             If theObject is null or contains no non-whitespace characters
024         */
025        public static void notBlank(String theObject, String theName) {
026                assert theName != null;
027
028                if (theObject == null) {
029                        throw new IllegalArgumentException(theName + " can not be null");
030                }
031
032                if (theObject.trim().length() == 0) {
033                        throw new IllegalArgumentException(theName + " can not be empty");
034                }
035        }
036
037        public static void propertySet(Object theValue, String theName) {
038                if (theValue == null) {
039                        throw new IllegalStateException("Property \"" + theName + "\" is not set");
040                }
041        }
042
043}