}
if (obj.getClass().isEnum()) {
hasher.write(((Enum<?>) obj).name());
} else if (obj.getClass().isArray()) {
if (obj.getClass().getComponentType().isPrimitive()) {
Serializer serializer = HashGenericRecordSerializers.getPrimitiveArraySerializer(obj.getClass().getComponentType());
if (serializer == null) {
throw new RuntimeException("Can't find serializer for array of type:" + obj.getClass());
}
serializer.serialize(hasher, obj);
} else {
Object[] objects = (Object[]) obj;
for (Object object : objects) {
write(object);
}
}
} else {
Serializer serializer = HashGenericRecordSerializers.getTypeSerializer(obj.getClass());
if (serializer == null) {
throw new RuntimeException("Can't find serializer for type:" + obj.getClass());
}
serializer.serialize(hasher, obj);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}