if (data != null) {
fieldMetadata = metadataMap.get(data.getKey());
if (fieldMetadata != null && fieldMetadata.getConstructorInjection().isPresent()) {
ThriftConstructorInjection constructor = fieldMetadata.getConstructorInjection().get();
Object[] parametersValues = new Object[] { data.getValue() };
try {
instance = constructor.getConstructor().newInstance(parametersValues);
}
catch (InvocationTargetException e) {
if (e.getTargetException() != null) {
Throwables.propagateIfInstanceOf(e.getTargetException(), Exception.class);
}
throw e;
}
}
}
if (instance == null && metadata.getConstructorInjection().isPresent()) {
ThriftConstructorInjection constructor = metadata.getConstructorInjection().get();
// must be no-args
Object[] parametersValues = new Object[0];
try {
instance = constructor.getConstructor().newInstance(parametersValues);
}
catch (InvocationTargetException e) {
if (e.getTargetException() != null) {
Throwables.propagateIfInstanceOf(e.getTargetException(), Exception.class);
}