protected Object getFieldValue(Object instance, ThriftFieldMetadata field)
throws Exception
{
try {
if (field.getExtraction().isPresent()) {
ThriftExtraction extraction = field.getExtraction().get();
if (extraction instanceof ThriftFieldExtractor) {
ThriftFieldExtractor thriftFieldExtractor = (ThriftFieldExtractor) extraction;
return thriftFieldExtractor.getField().get(instance);
}
else if (extraction instanceof ThriftMethodExtractor) {
ThriftMethodExtractor thriftMethodExtractor = (ThriftMethodExtractor) extraction;
return thriftMethodExtractor.getMethod().invoke(instance);
}
throw new IllegalAccessException("Unsupported field extractor type " + extraction.getClass().getName());
}
throw new IllegalAccessException("No extraction present for " + field);
}
catch (InvocationTargetException e) {
if (e.getTargetException() != null) {