AvroUtil { public static boolean allowsNull(Schema schema) { if (schema.getType() == Type.UNION) { for (Schema sch : schema.getTypes()) { if (sch.getType() == Type.NULL) return true; } }; return false; } private  AvroUtil(); static boolean isRecordType(Schema schema); static Type primaryTypeIn(Schema schema); static boolean allowsNull(Schema schema); static Schema parseSchema(String schemaString); static Schema schemaFrom(URL url); static String childIntNodeAsString(Field field, String childId); static String defaultFor(Field field); static boolean denotesPrimitiveValue(Schema schema); static boolean isNullableSingleType(Field field); static boolean isNullableSingleType(List<Schema> types); static Schema nonNullSchemaIn(List<Schema> types); static Schema nullableSingleTypeIn(List<Schema> types);  }
@Test public void allowsNull() { assertFalse( AvroUtil.allowsNull(Person.SCHEMA$) ); Field field = Person.SCHEMA$.getField("birthdate"); assertTrue( AvroUtil.allowsNull( field.schema() )); field = Person.SCHEMA$.getField("lastname"); assertFalse( AvroUtil.allowsNull( field.schema() )); field = Person.SCHEMA$.getField("latitude"); assertTrue( AvroUtil.allowsNull( field.schema() )); }