Search in sources :

Example 1 with MetadataScope

use of org.mule.runtime.extension.api.annotation.metadata.MetadataScope in project mule by mulesoft.

the class CustomStaticTypeDeclarationEnricher method getAttributesType.

private Optional<MetadataType> getAttributesType(AnnotatedElement element) {
    AttributesXmlType xml = element.getAnnotation(AttributesXmlType.class);
    if (xml != null) {
        return getXmlType(xml.schema(), xml.qname());
    }
    AttributesJsonType json = element.getAnnotation(AttributesJsonType.class);
    if (json != null) {
        return getJsonType(json.schema());
    }
    OutputResolver resolver = element.getAnnotation(OutputResolver.class);
    if (resolver != null && isStaticResolver(resolver.attributes())) {
        return getCustomStaticType(resolver.attributes());
    }
    MetadataScope scope = element.getAnnotation(MetadataScope.class);
    if (scope != null && isStaticResolver(scope.attributesResolver())) {
        return getCustomStaticType(scope.attributesResolver());
    }
    return empty();
}
Also used : AttributesXmlType(org.mule.runtime.extension.api.annotation.metadata.fixed.AttributesXmlType) OutputResolver(org.mule.runtime.extension.api.annotation.metadata.OutputResolver) AttributesJsonType(org.mule.runtime.extension.api.annotation.metadata.fixed.AttributesJsonType) MetadataScope(org.mule.runtime.extension.api.annotation.metadata.MetadataScope)

Example 2 with MetadataScope

use of org.mule.runtime.extension.api.annotation.metadata.MetadataScope in project mule by mulesoft.

the class CustomStaticTypeDeclarationEnricher method getOutputType.

private Optional<MetadataType> getOutputType(AnnotatedElement element) {
    OutputXmlType xml = element.getAnnotation(OutputXmlType.class);
    if (xml != null) {
        return getXmlType(xml.schema(), xml.qname());
    }
    OutputJsonType json = element.getAnnotation(OutputJsonType.class);
    if (json != null) {
        return getJsonType(json.schema());
    }
    OutputResolver resolver = element.getAnnotation(OutputResolver.class);
    if (resolver != null && isStaticResolver(resolver.output())) {
        return getCustomStaticType(resolver.output());
    }
    MetadataScope scope = element.getAnnotation(MetadataScope.class);
    if (scope != null && isStaticResolver(scope.outputResolver())) {
        return getCustomStaticType(scope.outputResolver());
    }
    return empty();
}
Also used : OutputResolver(org.mule.runtime.extension.api.annotation.metadata.OutputResolver) OutputJsonType(org.mule.runtime.extension.api.annotation.metadata.fixed.OutputJsonType) OutputXmlType(org.mule.runtime.extension.api.annotation.metadata.fixed.OutputXmlType) MetadataScope(org.mule.runtime.extension.api.annotation.metadata.MetadataScope)

Example 3 with MetadataScope

use of org.mule.runtime.extension.api.annotation.metadata.MetadataScope in project mule by mulesoft.

the class MetadataScopeAdapter method initializeFromClass.

private void initializeFromClass(Type extensionType, WithDeclaringClass annotatedType, WithOutputDeclaration declaration) {
    // TODO MULE-10891: Add support for Source Callback parameters
    Optional<Class<?>> extensionClass = extensionType.getDeclaringClass();
    Optional<Class<?>> componentClass = annotatedType.getDeclaringClass();
    if (componentClass.isPresent() && extensionClass.isPresent()) {
        MetadataScope scope = getAnnotation(componentClass.get(), MetadataScope.class);
        scope = scope != null ? scope : getAnnotation(extensionClass.get(), MetadataScope.class);
        if (scope != null && !hasCustomStaticType(declaration.getOutput())) {
            this.keysResolver = ResolverSupplier.of(scope.keysResolver());
            this.outputResolver = ResolverSupplier.of(scope.outputResolver());
            this.attributesResolver = ResolverSupplier.of(scope.attributesResolver());
        }
    }
}
Also used : WithDeclaringClass(org.mule.runtime.module.extension.api.loader.java.type.WithDeclaringClass) MetadataScope(org.mule.runtime.extension.api.annotation.metadata.MetadataScope)

Aggregations

MetadataScope (org.mule.runtime.extension.api.annotation.metadata.MetadataScope)3 OutputResolver (org.mule.runtime.extension.api.annotation.metadata.OutputResolver)2 AttributesJsonType (org.mule.runtime.extension.api.annotation.metadata.fixed.AttributesJsonType)1 AttributesXmlType (org.mule.runtime.extension.api.annotation.metadata.fixed.AttributesXmlType)1 OutputJsonType (org.mule.runtime.extension.api.annotation.metadata.fixed.OutputJsonType)1 OutputXmlType (org.mule.runtime.extension.api.annotation.metadata.fixed.OutputXmlType)1 WithDeclaringClass (org.mule.runtime.module.extension.api.loader.java.type.WithDeclaringClass)1