Search in sources :

Example 1 with StereotypeModelBuilder

use of org.mule.runtime.api.meta.model.stereotype.StereotypeModelBuilder in project mule by mulesoft.

the class StereotypeResolver method getStereotype.

protected static StereotypeModel getStereotype(StereotypeDefinition stereotypeDefinition, String namespace, Map<StereotypeDefinition, StereotypeModel> stereotypesCache) {
    return stereotypesCache.computeIfAbsent(stereotypeDefinition, definition -> {
        if (!isValidStereotype(stereotypeDefinition, namespace)) {
            throw new IllegalModelDefinitionException(format("Stereotype '%s' defines namespace '%s' which doesn't match extension stereotype '%s'. No extension can define " + "stereotypes on namespaces other than its own", stereotypeDefinition.getName(), stereotypeDefinition.getNamespace(), namespace));
        }
        final StereotypeModelBuilder builder = newStereotype(stereotypeDefinition.getName(), namespace);
        stereotypeDefinition.getParent().ifPresent(parent -> {
            String parentNamespace = parent.getNamespace();
            if (isBlank(parentNamespace)) {
                parentNamespace = namespace;
            }
            builder.withParent(getStereotype(parent, parentNamespace, stereotypesCache));
        });
        return builder.build();
    });
}
Also used : IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) StereotypeModelBuilder(org.mule.runtime.api.meta.model.stereotype.StereotypeModelBuilder)

Aggregations

StereotypeModelBuilder (org.mule.runtime.api.meta.model.stereotype.StereotypeModelBuilder)1 IllegalModelDefinitionException (org.mule.runtime.extension.api.exception.IllegalModelDefinitionException)1