### Question:
GenericData { public int hashCode(Object o, Schema s) { if (o == null) return 0; int hashCode = 1; switch (s.getType()) { case RECORD: for (Field f : s.getFields()) { if (f.order() == Field.Order.IGNORE) continue; hashCode = hashCodeAdd(hashCode, getField(o, f.name(), f.pos()), f.schema()); } return hashCode; case ARRAY: Collection<?> a = (Collection<?>) o; Schema elementType = s.getElementType(); for (Object e : a) hashCode = hashCodeAdd(hashCode, e, elementType); return hashCode; case UNION: return hashCode(o, s.getTypes().get(resolveUnion(s, o))); case ENUM: return s.getEnumOrdinal(o.toString()); case NULL: return 0; case STRING: return (o instanceof Utf8 ? o : new Utf8(o.toString())).hashCode(); default: return o.hashCode(); } } GenericData();  GenericData(ClassLoader classLoader); static void setStringType(Schema s, StringType stringType); static GenericData get(); ClassLoader getClassLoader(); Collection<Conversion<?>> getConversions(); void addLogicalTypeConversion(Conversion<?> conversion); @SuppressWarnings("unchecked") Conversion<T> getConversionByClass(Class<T> datumClass); @SuppressWarnings("unchecked") Conversion<T> getConversionByClass(Class<T> datumClass, LogicalType logicalType); @SuppressWarnings("unchecked") Conversion<Object> getConversionFor(LogicalType logicalType); GenericData setFastReaderEnabled(boolean flag); boolean isFastReaderEnabled(); FastReaderBuilder getFastReaderBuilder(); DatumReader createDatumReader(Schema schema); DatumReader createDatumReader(Schema writer, Schema reader); DatumWriter createDatumWriter(Schema schema); boolean validate(Schema schema, Object datum); String toString(Object datum); Schema induce(Object datum); void setField(Object record, String name, int position, Object value); Object getField(Object record, String name, int position); int resolveUnion(Schema union, Object datum); int hashCode(Object o, Schema s); int compare(Object o1, Object o2, Schema s); @SuppressWarnings({ "unchecked" }) Object getDefaultValue(Field field); @SuppressWarnings({ "rawtypes", "unchecked" }) T deepCopy(Schema schema, T value); Object createFixed(Object old, Schema schema); Object createFixed(Object old, byte[] bytes, Schema schema); Object createEnum(String symbol, Schema schema); Object newRecord(Object old, Schema schema); Object createString(Object value); Object newArray(Object old, int size, Schema schema); Object newMap(Object old, int size); InstanceSupplier getNewRecordSupplier(Schema schema); static final String STRING_PROP; static final String FAST_READER_PROP; }### Answer:
@Test public void testHashCode() { GenericData.get().hashCode(null, Schema.create(Type.NULL)); GenericData.get().hashCode(null, Schema.createUnion(Arrays.asList(Schema.create(Type.BOOLEAN), Schema.create(Type.STRING)))); List<CharSequence> stuff = new ArrayList<>(); stuff.add("string"); Schema schema = recordSchema(); GenericRecord r = new GenericData.Record(schema); r.put(0, stuff); GenericData.get().hashCode(r, schema); }