use of org.mule.runtime.api.metadata.resolving.PartialTypeKeysResolver in project mule by mulesoft.
the class MetadataKeysDelegate method getMetadataKeys.
MetadataResult<MetadataKeysContainer> getMetadataKeys(MetadataContext context, Object partialKey, ReflectionCache reflectionCache) {
final TypeKeysResolver keyResolver = resolverFactory.getKeyResolver();
final String componentResolverName = keyResolver.getCategoryName();
final MetadataKeysContainerBuilder keysContainer = MetadataKeysContainerBuilder.getInstance();
if (keyParts.isEmpty()) {
return success(keysContainer.add(componentResolverName, ImmutableSet.of(new NullMetadataKey())).build());
}
try {
final Map<Integer, ParameterModel> partsByOrder = getPartOrderMapping(keyParts);
Set<MetadataKey> metadataKeys;
if (keyResolver instanceof PartialTypeKeysResolver && hasInitialLevel(partialKey, partsByOrder, reflectionCache)) {
metadataKeys = singleton(((PartialTypeKeysResolver) keyResolver).resolveChilds(context, partialKey));
} else {
metadataKeys = keyResolver.getKeys(context);
}
final Set<MetadataKey> enrichedMetadataKeys = metadataKeys.stream().map(metadataKey -> cloneAndEnrichMetadataKey(metadataKey, partsByOrder)).map(MetadataKeyBuilder::build).collect(toSet());
keysContainer.add(componentResolverName, enrichedMetadataKeys);
return success(keysContainer.build());
} catch (Exception e) {
return failure(newFailure(e).onKeys());
}
}
Aggregations