private Tuple randomTuple(int numFields, boolean includeNestedObjects) {
		Class<?>[] types = new Class<?>[] {int.class, boolean.class, char.class, long.class, float.class,
				double.class, byte.class, Byte.class, Integer.class, Boolean.class, Long.class, Double.class,
				String.class, Foo.class, Tuple.class};

		int range = includeNestedObjects ? types.length : types.length - 2;

		TupleBuilder tupleBuilder = new TupleBuilder();
		for (int i = 0; i < numFields; i++) {

			String name = "field" + i;
			Class<?> type = types[random.nextInt(range)];

			Object value = null;
			if (type.equals(int.class)) {
				value = random.nextInt();
			}
			else if (type.equals(Integer.class)) {
				value = new Integer(random.nextInt());
			}
			else if (type.equals(boolean.class)) {
				value = random.nextBoolean();
			}
			else if (type.equals(Boolean.class)) {
				value = new Boolean(random.nextBoolean());
			}
			else if (type.equals(char.class)) {
				value = 'q';
			}
			else if (type.equals(long.class)) {
				value = Math.abs(random.nextLong());
			}
			else if (type.equals(Long.class)) {
				value = Math.abs(new Long(random.nextLong()));
			}
			else if (type.equals(byte.class)) {
				value = (byte) random.nextInt(127);
			}
			else if (type.equals(Byte.class)) {
				value = new Byte((byte) random.nextInt(127));
			}

			else if (type.equals(float.class)) {
				value = random.nextFloat();
			}
			else if (type.equals(Float.class)) {
				value = new Float(random.nextFloat());
			}

			else if (type.equals(double.class)) {
				value = random.nextDouble();
			}
			else if (type.equals(Double.class)) {
				value = new Double(random.nextDouble());
			}

			else if (type.equals(String.class)) {
				value = new BigInteger(130, random).toString(32);
			}

			else if (type.equals(Foo.class)) {
				value = new Foo();
			}
			else if (type.equals(Tuple.class)) {
				value = randomTuple(5, false);
			}
			tupleBuilder.put(name, value);
		}
		return tupleBuilder.build();
	}
@author David Turanski
@author Gary Russell
spring-xd-benchmark/src/test/java/org/springframework/xd/tuple/serializer/kryo/TupleCodecBenchmarkTests.java