Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.util » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements. See the NOTICE file distributed with this
    4    * work for additional information regarding copyright ownership. The ASF
    5    * licenses this file to You under the Apache License, Version 2.0 (the
    6    * "License"); you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
    9    * or agreed to in writing, software distributed under the License is
   10    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   11    * KIND, either express or implied. See the License for the specific language
   12    * governing permissions and limitations under the License.
   13    */
   14   package org.apache.webbeans.util;
   15   
   16   import java.lang.reflect.Method;
   17   
   18   import org.dom4j.Element;
   19   
   20   /**
   21    * Simple utility classes with some assertions methods.
   22    * 
   23    * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
   24    * @since 1.0
   25    */
   26   public final class Asserts
   27   {
   28   
   29       /*
   30        * Private constructor
   31        */
   32       private Asserts()
   33       {
   34           throw new UnsupportedOperationException();
   35       }
   36   
   37       /**
   38        * Check the object is null or not
   39        * 
   40        * @param obj null check object
   41        * @param message exception message
   42        */
   43       public static void assertNotNull(Object obj, String message)
   44       {
   45           if (obj == null)
   46           {
   47               throw new NullPointerException(message);
   48           }
   49       }
   50   
   51       /**
   52        * Check the object is null or not
   53        * 
   54        * @param obj null check object
   55        */
   56       public static void assertNotNull(Object obj)
   57       {
   58           if (obj == null)
   59           {
   60               throw new NullPointerException();
   61           }
   62       }
   63   
   64       /**
   65        * Null check for type modifiers.
   66        * 
   67        * @param modifier modifier parameter check
   68        */
   69       public static void nullCheckForModifier(Integer modifier)
   70       {
   71           Asserts.assertNotNull(modifier, "modifier argument can not be null");
   72       }
   73   
   74       /**
   75        * Null check for class parameter.
   76        * 
   77        * @param clazz parameter
   78        */
   79       public static void nullCheckForClass(Class<?> clazz)
   80       {
   81           Asserts.assertNotNull(clazz, "clazz argument can not be null");
   82       }
   83   
   84       /**
   85        * Null check for class parameter.
   86        * 
   87        * @param clazz parameter
   88        */
   89       public static void nullCheckForClass(Class<?> clazz, String message)
   90       {
   91           Asserts.assertNotNull(clazz, message);
   92       }
   93   
   94       /**
   95        * Null check for method parameter.
   96        * 
   97        * @param method parameter
   98        */
   99       public static void nullCheckForMethod(Method method)
  100       {
  101           Asserts.assertNotNull(method, "method argument can not be null");
  102       }
  103   
  104       /**
  105        * Null check for element parameter.
  106        * 
  107        * @param element parameter
  108        */
  109       public static void nullCheckForDomElement(Element element)
  110       {
  111           Asserts.assertNotNull(element, "element argument can not be null");
  112       }
  113   
  114   }

Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.util » [javadoc | source]