/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.aspects;

/**
 * Comment
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 * @version $Revision: 1.1.8.3 $
 */
public class NullOrZero
{
   private static final Long LONG_ZERO = new Long(0);
   private static final Short SHORT_ZERO = new Short((short) 0);
   private static final Integer INT_ZERO = new Integer(0);
   private static final Float FLOAT_ZERO = new Float(0.0);
   private static final Double DOUBLE_ZERO = new Double(0.0);
   private static final Character CHAR_ZERO = new Character('\0');
   private static final Byte BYTE_ZERO = new Byte((byte) 0);


   public static Object nullOrZero(Class type)
   {
      if (!type.isPrimitive()) return null;
      if (type.equals(void.class)) return null;
      if (type.equals(long.class)) return LONG_ZERO;
      if (type.equals(short.class)) return SHORT_ZERO;
      if (type.equals(int.class)) return INT_ZERO;
      if (type.equals(float.class)) return FLOAT_ZERO;
      if (type.equals(double.class)) return DOUBLE_ZERO;
      if (type.equals(char.class)) return CHAR_ZERO;
      if (type.equals(byte.class)) return BYTE_ZERO;

      return null;
   }
}
