Not all primitive types are taken care of. Maybe the isPrimitive method should be used here?