use of org.mule.runtime.module.extension.internal.runtime.ValueResolvingException in project mule by mulesoft.
the class ObjectBasedParameterValueResolver method getParameterValue.
@Override
public Object getParameterValue(String parameterName) throws ValueResolvingException {
try {
Optional<Field> field = getField(object.getClass(), parameterName, reflectionCache);
if (field.isPresent()) {
return getFieldValue(object, parameterName, reflectionCache);
} else {
for (ParameterGroupModel parameterGroupModel : parameterizedModel.getParameterGroupModels()) {
Optional<ParameterGroupModelProperty> modelProperty = parameterGroupModel.getModelProperty(ParameterGroupModelProperty.class);
if (modelProperty.isPresent()) {
ParameterGroupModelProperty property = modelProperty.get();
Field container = (Field) property.getDescriptor().getContainer();
Object parameterGroup = getFieldValue(object, container.getName(), reflectionCache);
Optional<Field> desiredField = getField(parameterGroup.getClass(), parameterName, reflectionCache);
if (desiredField.isPresent()) {
return getFieldValue(parameterGroup, parameterName, reflectionCache);
}
}
}
}
} catch (Exception e) {
throw new ValueResolvingException("An error occurred trying to obtain the value for the parameter: " + parameterName);
}
throw new ValueResolvingException("Unable to resolve value for the parameter: " + parameterName);
}
Aggregations