if (fieldMetadata != null) {
// inject fields
for (ThriftInjection injection : fieldMetadata.getInjections()) {
if (injection instanceof ThriftFieldInjection) {
ThriftFieldInjection fieldInjection = (ThriftFieldInjection) injection;
if (data.getValue() != null) {
fieldInjection.getField().set(instance, data.getValue());
}
}
}
if (fieldMetadata.getMethodInjection().isPresent()) {
Object[] parametersValues = new Object[] { data.getValue() };
if (data.getValue() != null) {
try {
fieldMetadata.getMethodInjection().get().getMethod().invoke(instance, parametersValues);
}
catch (InvocationTargetException e) {
if (e.getTargetException() != null) {
Throwables.propagateIfInstanceOf(e.getTargetException(), Exception.class);
}
throw e;
}
}
}
}
if (data != null) {
// inject id value
for (ThriftInjection injection : idField.getKey().getInjections()) {
if (injection instanceof ThriftFieldInjection) {
ThriftFieldInjection fieldInjection = (ThriftFieldInjection) injection;
fieldInjection.getField().set(instance, data.getKey());
}
}
// builder method
if (metadata.getBuilderMethod().isPresent()) {