Search in sources :

Example 1 with UnionType

use of org.mule.metadata.api.model.UnionType in project mule by mulesoft.

the class DefaultExtensionBuildingDefinitionProvider method registerTopLevelParameter.

private void registerTopLevelParameter(final MetadataType parameterType, Builder definitionBuilder, ClassLoader extensionClassLoader, DslSyntaxResolver dslSyntaxResolver, ExtensionParsingContext parsingContext, ReflectionCache reflectionCache) {
    Optional<DslElementSyntax> dslElement = dslSyntaxResolver.resolve(parameterType);
    if (!dslElement.isPresent() || parsingContext.isRegistered(dslElement.get().getElementName(), dslElement.get().getPrefix()) || !IntrospectionUtils.isInstantiable(parameterType, reflectionCache)) {
        return;
    }
    parameterType.accept(new MetadataTypeVisitor() {

        @Override
        public void visitObject(ObjectType objectType) {
            DslElementSyntax pojoDsl = dslElement.get();
            if (pojoDsl.supportsTopLevelDeclaration() || (pojoDsl.supportsChildDeclaration() && pojoDsl.isWrapped()) || getSubstitutionGroup(objectType).isPresent() || parsingContext.getAllSubTypes().contains(objectType)) {
                parseWith(new ObjectTypeParameterParser(definitionBuilder, objectType, extensionClassLoader, dslSyntaxResolver, parsingContext));
            }
            registerSubTypes(objectType, definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
        }

        @Override
        public void visitArrayType(ArrayType arrayType) {
            registerTopLevelParameter(arrayType.getType(), definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
        }

        @Override
        public void visitUnion(UnionType unionType) {
            unionType.getTypes().forEach(type -> type.accept(this));
        }
    });
}
Also used : ArrayType(org.mule.metadata.api.model.ArrayType) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) ComponentBuildingDefinitionProvider(org.mule.runtime.dsl.api.component.ComponentBuildingDefinitionProvider) IntrospectionUtils(org.mule.runtime.module.extension.internal.util.IntrospectionUtils) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ArrayType(org.mule.metadata.api.model.ArrayType) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) UnionType(org.mule.metadata.api.model.UnionType) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) Preconditions.checkState(org.mule.runtime.api.util.Preconditions.checkState) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) OperationDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.operation.OperationDefinitionParser) ObjectType(org.mule.metadata.api.model.ObjectType) ConstructDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.construct.ConstructDefinitionParser) ConfigurationDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.config.ConfigurationDefinitionParser) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ExtensionMetadataTypeUtils.getSubstitutionGroup(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getSubstitutionGroup) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) List(java.util.List) Stream(java.util.stream.Stream) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) SourceDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.source.SourceDefinitionParser) XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) Optional(java.util.Optional) Builder(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition.Builder) ConnectionProviderDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.connection.ConnectionProviderDefinitionParser) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) MuleExtensionUtils.getClassLoader(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.getClassLoader) ComponentLocationVisitor(org.mule.runtime.config.internal.dsl.model.ComponentLocationVisitor) ObjectTypeParameterParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.ObjectTypeParameterParser) CustomBuildingDefinitionProviderModelProperty(org.mule.runtime.core.internal.extension.CustomBuildingDefinitionProviderModelProperty) ImmutableList(com.google.common.collect.ImmutableList) ExtensionBuildingDefinitionProvider(org.mule.runtime.module.extension.internal.config.ExtensionBuildingDefinitionProvider) ClassUtils.withContextClassLoader(org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader) LinkedList(java.util.LinkedList) ModuleOperationMessageProcessorChainBuilder(org.mule.runtime.core.internal.processor.chain.ModuleOperationMessageProcessorChainBuilder) TypeDefinition.fromType(org.mule.runtime.dsl.api.component.TypeDefinition.fromType) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) XmlExtensionModelProperty(org.mule.runtime.extension.api.property.XmlExtensionModelProperty) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) ObjectType(org.mule.metadata.api.model.ObjectType) ObjectTypeParameterParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.ObjectTypeParameterParser) UnionType(org.mule.metadata.api.model.UnionType) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 ArrayType (org.mule.metadata.api.model.ArrayType)1 MetadataType (org.mule.metadata.api.model.MetadataType)1 ObjectType (org.mule.metadata.api.model.ObjectType)1 UnionType (org.mule.metadata.api.model.UnionType)1 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)1 DslResolvingContext (org.mule.runtime.api.dsl.DslResolvingContext)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 XmlDslModel (org.mule.runtime.api.meta.model.XmlDslModel)1 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)1 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)1 ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)1 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)1 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)1