@Test public void testDefaultValue() { assertNull(ReflectionUtils.getDefaultValue(Integer.class)); assertEquals( null, ReflectionUtils.getDefaultValue(void.class)); assertEquals( Boolean.valueOf(false), ReflectionUtils.getDefaultValue(boolean.class)); assertEquals( Byte.valueOf((byte) 0), ReflectionUtils.getDefaultValue(byte.class)); assertEquals( Character.valueOf((char) 0), ReflectionUtils.getDefaultValue(char.class)); assertEquals( Short.valueOf((short) 0), ReflectionUtils.getDefaultValue(short.class)); assertEquals( Integer.valueOf(0), ReflectionUtils.getDefaultValue(int.class)); assertEquals( Long.valueOf(0L), ReflectionUtils.getDefaultValue(long.class)); assertEquals( Float.valueOf(0F), ReflectionUtils.getDefaultValue(float.class)); assertEquals( Double.valueOf(0D), ReflectionUtils.getDefaultValue(double.class)); }
public static Object getDefaultValue(Class<?> c) { if (!c.isPrimitive()) { return null; } if (c == boolean.class) { return false; } else if (c == byte.class) { return (byte) 0; } else if (c == char.class) { return (char) 0; } else if (c == short.class) { return (short) 0; } else if (c == int.class) { return 0; } else if (c == long.class) { return 0L; } else if (c == float.class) { return 0F; } else if (c == double.class) { return 0D; } return null; }
ReflectionUtils { public static Object getDefaultValue(Class<?> c) { if (!c.isPrimitive()) { return null; } if (c == boolean.class) { return false; } else if (c == byte.class) { return (byte) 0; } else if (c == char.class) { return (char) 0; } else if (c == short.class) { return (short) 0; } else if (c == int.class) { return 0; } else if (c == long.class) { return 0L; } else if (c == float.class) { return 0F; } else if (c == double.class) { return 0D; } return null; } }
ReflectionUtils { public static Object getDefaultValue(Class<?> c) { if (!c.isPrimitive()) { return null; } if (c == boolean.class) { return false; } else if (c == byte.class) { return (byte) 0; } else if (c == char.class) { return (char) 0; } else if (c == short.class) { return (short) 0; } else if (c == int.class) { return 0; } else if (c == long.class) { return 0L; } else if (c == float.class) { return 0F; } else if (c == double.class) { return 0D; } return null; }  }
ReflectionUtils { public static Object getDefaultValue(Class<?> c) { if (!c.isPrimitive()) { return null; } if (c == boolean.class) { return false; } else if (c == byte.class) { return (byte) 0; } else if (c == char.class) { return (char) 0; } else if (c == short.class) { return (short) 0; } else if (c == int.class) { return 0; } else if (c == long.class) { return 0L; } else if (c == float.class) { return 0F; } else if (c == double.class) { return 0D; } return null; }  static Object getDefaultValue(Class<?> c); static Class<?> getNonPrimitiveClass(Class<?> c); static String getPackageName(Class<?> c); static Object callStaticMethod(
            String classAndMethod, Object... params); static Object callMethod(
            Object instance,
            String methodName,
            Object... params); }
ReflectionUtils { public static Object getDefaultValue(Class<?> c) { if (!c.isPrimitive()) { return null; } if (c == boolean.class) { return false; } else if (c == byte.class) { return (byte) 0; } else if (c == char.class) { return (char) 0; } else if (c == short.class) { return (short) 0; } else if (c == int.class) { return 0; } else if (c == long.class) { return 0L; } else if (c == float.class) { return 0F; } else if (c == double.class) { return 0D; } return null; }  static Object getDefaultValue(Class<?> c); static Class<?> getNonPrimitiveClass(Class<?> c); static String getPackageName(Class<?> c); static Object callStaticMethod(
            String classAndMethod, Object... params); static Object callMethod(
            Object instance,
            String methodName,
            Object... params);  }