1 22 package org.jboss.aspects; 23 24 30 public class NullOrZero 31 { 32 private static final Long LONG_ZERO = new Long (0); 33 private static final Short SHORT_ZERO = new Short ((short) 0); 34 private static final Integer INT_ZERO = new Integer (0); 35 private static final Float FLOAT_ZERO = new Float (0.0); 36 private static final Double DOUBLE_ZERO = new Double (0.0); 37 private static final Character CHAR_ZERO = new Character ('\0'); 38 private static final Byte BYTE_ZERO = new Byte ((byte) 0); 39 private static final Boolean BOOLEAN_ZERO = Boolean.FALSE; 40 41 42 public static Object nullOrZero(Class type) 43 { 44 if (!type.isPrimitive()) return null; 45 if (type.equals(void.class)) return null; 46 if (type.equals(long.class)) return LONG_ZERO; 47 if (type.equals(short.class)) return SHORT_ZERO; 48 if (type.equals(int.class)) return INT_ZERO; 49 if (type.equals(float.class)) return FLOAT_ZERO; 50 if (type.equals(double.class)) return DOUBLE_ZERO; 51 if (type.equals(char.class)) return CHAR_ZERO; 52 if (type.equals(byte.class)) return BYTE_ZERO; 53 54 return null; 55 } 56 } 57 | Popular Tags |