public <T> T resolveModel(Class<T> modelClass, T unresolved) {
// Lookup a definition for the given namespace
QName qname = ((ConstrainingType)unresolved).getName();
ConstrainingType resolved = (ConstrainingType) map.get(qname);
if (resolved != null) {
return modelClass.cast(resolved);
}
// No definition found, delegate the resolution to the imports
for (Import import_ : this.contribution.getImports()) {
if (import_ instanceof NamespaceImport) {
NamespaceImport namespaceImport = (NamespaceImport)import_;
if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
// Delegate the resolution to the import resolver
resolved = namespaceImport.getModelResolver().resolveModel(ConstrainingType.class, (ConstrainingType)unresolved);
if (!resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
}
}
}