// Check if this is a self-import
boolean selfImport = false;
List<ExportPackage> matchingExports = exports.get(pkgName);
if (matchingExports != null) {
String versionRangeStr = importAttribs.get(Constants.VERSION_ATTRIBUTE);
VersionRange versionRange = (versionRangeStr != null) ? new VersionRange(versionRangeStr) : new VersionRange("0");
for (ExportPackage export : matchingExports) {
String versionStr = export.getAttribs().get(Constants.VERSION_ATTRIBUTE);
Version version = (versionStr != null) ? new Version(versionStr) : new Version(0);
if (versionRange.includes(version)) {
selfImport = true;
break;
}
}
}
ImportPackage importPackage = new ImportPackage(pkgName, selfImport, importAttribs, usedBy.get(pkgName), classMap);
List<ImportPackage> importList = imports.get(pkgName);
if (importList == null) {
importList = new LinkedList<ImportPackage>();
imports.put(pkgName, importList);
}
importList.add(importPackage);
}
// Process require-bundles
String requireBundlesStr = attribs.getValue(Constants.REQUIRE_BUNDLE);
final Parameters requiredBundleMap = new Parameters(requireBundlesStr);
for (Entry<String,Attrs> entry : requiredBundleMap.entrySet()) {
String name = entry.getKey();
Attrs rbAttribs = entry.getValue();
// Check if the required bundle is already included in the closure
boolean satisfied = false;
Set<Version> includedVersions = bundleVersions.get(name);
if (includedVersions != null) {
String versionRangeStr = rbAttribs.get(Constants.BUNDLE_VERSION_ATTRIBUTE);
VersionRange versionRange = (versionRangeStr != null) ? new VersionRange(versionRangeStr) : new VersionRange("0");
for (Version includedVersion : includedVersions) {
if (versionRange.includes(includedVersion)) {
satisfied = true;
break;
}
}
}