Struct { public Struct put(String fieldName, Object value) { Field field = lookupField(fieldName); return put(field, value); } Struct(Schema schema); Schema schema(); Object get(String fieldName); Object get(Field field); Object getWithoutDefault(String fieldName); Byte getInt8(String fieldName); Short getInt16(String fieldName); Integer getInt32(String fieldName); Long getInt64(String fieldName); Float getFloat32(String fieldName); Double getFloat64(String fieldName); Boolean getBoolean(String fieldName); String getString(String fieldName); byte[] getBytes(String fieldName); @SuppressWarnings("unchecked") List<T> getArray(String fieldName); @SuppressWarnings("unchecked") Map<K, V> getMap(String fieldName); Struct getStruct(String fieldName); Struct put(String fieldName, Object value); Struct put(Field field, Object value); void validate(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test(expected = DataException.class) public void testInvalidFieldType() { new Struct(FLAT_STRUCT_SCHEMA).put("int8", "should fail because this is a string, not int8"); }
@Test(expected = DataException.class) public void testInvalidArrayFieldElements() { new Struct(NESTED_SCHEMA).put("array", Arrays.asList("should fail since elements should be int8s")); }
@Test(expected = DataException.class) public void testInvalidMapKeyElements() { new Struct(NESTED_SCHEMA).put("map", Collections.singletonMap("should fail because keys should be int8s", (byte) 12)); }
@Test(expected = DataException.class) public void testInvalidStructFieldSchema() { new Struct(NESTED_SCHEMA).put("nested", new Struct(MAP_SCHEMA)); }
@Test(expected = DataException.class) public void testInvalidStructFieldValue() { new Struct(NESTED_SCHEMA).put("nested", new Struct(NESTED_CHILD_SCHEMA)); }