use of org.mule.runtime.module.extension.internal.loader.java.type.runtime.ParameterizableTypeWrapper in project mule by mulesoft.
the class ValueProvidersParameterDeclarationEnricher method enrichParameter.
/**
* Enriches a parameter that has an associated {@link ValueProvider}
*
* @param resolverClass the class of the {@link ValueProvider}
* @param paramDeclaration {@link ParameterDeclaration} or {@link ParameterGroupDeclaration} paramDeclaration
* @param containerParameterNames parameters container's names
*/
private void enrichParameter(OfValues resolverClass, BaseDeclaration paramDeclaration, Consumer<ValueProviderModel> valueProviderModelConsumer, Integer partOrder, Map<String, String> containerParameterNames, String name) {
ValueProviderFactoryModelPropertyBuilder propertyBuilder = ValueProviderFactoryModelProperty.builder(resolverClass.value());
ParameterizableTypeWrapper resolverClassWrapper = new ParameterizableTypeWrapper(resolverClass.value(), new DefaultExtensionsTypeLoaderFactory().createTypeLoader());
List<ExtensionParameter> resolverParameters = resolverClassWrapper.getParametersAnnotatedWith(Parameter.class);
resolverParameters.forEach(param -> propertyBuilder.withInjectableParameter(param.getName(), param.getType().asMetadataType(), param.isRequired()));
Reference<Boolean> requiresConfiguration = new Reference<>(false);
Reference<Boolean> requiresConnection = new Reference<>(false);
enrichWithConnection(propertyBuilder, resolverClassWrapper).ifPresent(field -> requiresConnection.set(true));
enrichWithConfiguration(propertyBuilder, resolverClassWrapper).ifPresent(field -> requiresConfiguration.set(true));
paramDeclaration.addModelProperty(propertyBuilder.build());
valueProviderModelConsumer.accept(new ValueProviderModel(getRequiredParametersAliases(resolverParameters, containerParameterNames), requiresConfiguration.get(), requiresConnection.get(), resolverClass.open(), partOrder, name));
}
Aggregations