class PrimitiveTypeUtils {

    public static Object toWrapperListToPrimitiveArray(final List wrapperList, Class<?> primitiveType) {
        if (primitiveType.isArray()) {
            primitiveType = primitiveType.getComponentType();
        }

        if (boolean.class.equals(primitiveType)) {
            return Booleans.toArray(wrapperList);
        } else if (float.class.equals(primitiveType)) {
            return Floats.toArray(wrapperList);
        } else if (long.class.equals(primitiveType)) {
            return Longs.toArray(wrapperList);
        } else if (int.class.equals(primitiveType)) {
            return Ints.toArray(wrapperList);
        } else if (short.class.equals(primitiveType)) {
            return Shorts.toArray(wrapperList);
        } else if (byte.class.equals(primitiveType)) {
            return Bytes.toArray(wrapperList);
        } else if (double.class.equals(primitiveType)) {
            return Doubles.toArray(wrapperList);
        } else if (char.class.equals(primitiveType)) {
            return Chars.toArray(wrapperList);
        } else {
            throw new IllegalArgumentException(primitiveType.getName() + " is not a supported primitive type");
        }
    }

}