TupleKey { @SuppressWarnings("unchecked") T get(Object[] values) { return (T) values[index]; } TupleKey(TupleSchema schema, String name, int index); TupleKeyValue of(T value); String getName(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void keyBasedAccessToValues() { Tuple person = personSchema.makeWith("Dominic", 41, addressSchema.makeWith(asList("23 Acacia Avenue", "Sunderland"), "VB6 5UX")); assertThat(person.get(name), equalTo("Dominic")); assertThat(person.get(age), equalTo(41)); assertThat(person.get(address).get(addressLines), contains("23 Acacia Avenue", "Sunderland")); assertThat(person.get(address).get(postcode), equalTo("VB6 5UX")); }
@Test(expected=IllegalArgumentException.class) public void keyIsRefusedIfItBelongsToDifferentSchema() { Tuple person = personSchema.makeWith("Dominic", 41, addressSchema.makeWith(asList("23 Acacia Avenue", "Sunderland"), "VB6 5UX")); person.get(postcode); }