### Question:
Tuple implements Comparable<Tuple> { @Override public int compareTo(Tuple o) { checkArgument(o.getTypes().size() == types.size(), "types must be of same size"); for (int i = 0; i < types.size(); i++) { checkArgument(o.getTypes().get(i).equals(types.get(i)), "types must be the same"); } for (int i = 0; i < types.size(); i++) { Object o1 = values.get(i); Object o2 = o.getValues().get(i); int result = compare(o1, o2); if (result != 0) { return result; } } return 0; } Tuple(Type type, Object value);  Tuple(List<Type> types, Object... values);  Tuple(List<Type> types, List<Object> values); List<Type> getTypes(); List<Object> getValues(); @Override int compareTo(Tuple o); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testComparableTuple() { List<Type> types = ImmutableList.of(BIGINT, VARCHAR, BOOLEAN, DOUBLE, DATE, TIMESTAMP_MILLIS); Tuple tuple1 = new Tuple(types, ImmutableList.of(1L, "hello", false, 1.2d, 11111, 1112)); Tuple equalToTuple1 = new Tuple(types, ImmutableList.of(1L, "hello", false, 1.2d, 11111, 1112)); Tuple greaterThanTuple1 = new Tuple(types, ImmutableList.of(1L, "hello", false, 1.2d, 11111, 1113)); Tuple lessThanTuple1 = new Tuple(types, ImmutableList.of(1L, "hello", false, 1.2d, 11111, 1111)); assertEquals(tuple1.compareTo(equalToTuple1), 0); assertLessThan(tuple1.compareTo(greaterThanTuple1), 0); assertGreaterThan(tuple1.compareTo(lessThanTuple1), 0); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "types must be the same") public void testMismatchedTypes() { List<Type> types1 = ImmutableList.of(createVarcharType(3)); List<Type> types2 = ImmutableList.of(createVarcharType(4)); Tuple tuple1 = new Tuple(types1, ImmutableList.of("abc")); Tuple tuple2 = new Tuple(types2, ImmutableList.of("abcd")); tuple1.compareTo(tuple2); }