use of org.mule.runtime.api.meta.model.declaration.fluent.HasNestedComponentsDeclarer in project mule by mulesoft.
the class ParameterModelsLoaderDelegate method declare.
public List<ParameterDeclarer> declare(HasParametersDeclarer component, List<? extends ExtensionParameter> parameters, ParameterDeclarationContext declarationContext, ParameterGroupDeclarer parameterGroupDeclarer) {
List<ParameterDeclarer> declarerList = new ArrayList<>();
checkAnnotationsNotUsedMoreThanOnce(parameters, Connection.class, Config.class, MetadataKeyId.class);
boolean supportsNestedElements = component instanceof HasNestedComponentsDeclarer;
for (ExtensionParameter extensionParameter : parameters) {
// Both nested components and parameters are declared using the @Parameter annotation in order to simplify the API
if (supportsNestedElements && declaredAsNestedComponent((HasNestedComponentsDeclarer) component, extensionParameter)) {
continue;
}
if (!extensionParameter.shouldBeAdvertised()) {
continue;
}
if (isParameterGroup(extensionParameter)) {
List<ParameterDeclarer> groupParams = declaredAsGroup(component, declarationContext, extensionParameter);
declarerList.addAll(groupParams);
continue;
}
ParameterGroupDeclarer groupDeclarer = parameterGroupDeclarer != null ? parameterGroupDeclarer : component.onDefaultParameterGroup();
ParameterDeclarer parameter;
if (extensionParameter.isRequired()) {
parameter = groupDeclarer.withRequiredParameter(extensionParameter.getAlias());
} else {
parameter = groupDeclarer.withOptionalParameter(extensionParameter.getAlias()).defaultingTo(extensionParameter.defaultValue().isPresent() ? extensionParameter.defaultValue().get() : null);
}
parameter.ofType(extensionParameter.getType().asMetadataType()).describedAs(extensionParameter.getDescription());
parseParameterRole(extensionParameter, parameter);
parseExpressionSupport(extensionParameter, parameter);
parseConfigOverride(extensionParameter, parameter);
parseNullSafe(extensionParameter, parameter);
parseLayout(extensionParameter, parameter);
parseExclusiveOptional(extensionParameter, groupDeclarer, parameter);
parameter.withModelProperty(new ExtensionParameterDescriptorModelProperty(extensionParameter));
extensionParameter.getDeclaringElement().ifPresent(element -> addImplementingTypeModelProperty(element, parameter));
parseParameterDsl(extensionParameter, parameter);
contributors.forEach(contributor -> contributor.contribute(extensionParameter, parameter, declarationContext));
declarerList.add(parameter);
}
return declarerList;
}
Aggregations