clarifyLocator method
dynamic
clarifyLocator(
- dynamic locator,
- IFactory? factory
Clarifies a component locator by merging two descriptors into one to replace missing fields. That allows to get a more complete descriptor that includes all possible fields.
locator
a component locator to clarify.factory
a factory that shall create the component. Returns clarified component descriptor (locator)
Implementation
dynamic clarifyLocator(locator, IFactory? factory) {
if (factory == null) return locator;
if (!(locator is Descriptor)) return locator;
var anotherLocator = factory.canCreate(locator);
if (anotherLocator == null) return locator;
if (!(anotherLocator is Descriptor)) return locator;
var descriptor = locator;
var anotherDescriptor = anotherLocator;
return Descriptor(
descriptor.getGroup() ?? anotherDescriptor.getGroup(),
descriptor.getType() ?? anotherDescriptor.getType(),
descriptor.getKind() ?? anotherDescriptor.getKind(),
descriptor.getName() ?? anotherDescriptor.getName(),
descriptor.getVersion() ?? anotherDescriptor.getVersion());
}