@Override public int compare(Version v1, Version v2) { return v1.compareTo(v2); } }
@Override public int compareTo(ConfigModelId other) { if (other == this) return 0; int cmp = this.name.compareTo(other.name); if (cmp == 0) { cmp = this.version.compareTo(other.version); } return cmp; }
/** * Finds the best (highest) matching version among a set. * * @return the matching version, or null if there are no matches */ protected static Version findBestMatch(VersionSpecification versionSpec, Set<Version> versions) { Version bestMatch=null; for (Version version : versions) { //No version is set if getSpecifiedMajor() == null //In that case we allow all versions if (version == null || !versionSpec.matches(version)) continue; if (bestMatch==null || bestMatch.compareTo(version)<0) bestMatch=version; } return bestMatch; }
@Override public void handleVersion(Version version) { boolean shouldSend = false; synchronized (this) { if (version == null) { hasError = true; } else if (version.compareTo(this.version) < 0) { this.version = version; } if (--pending == 0) { shouldSend = true; } } if (shouldSend) { net.send(this); } } }
/** * Returns the bundle of a given name having the highest matching version * * @param id the id of the component to return. May not include a version, or include * an underspecified version, in which case the highest (mathcing) version which * does not contain a qualifier is returned * @return the bundle match having the highest version, or null if there was no matches */ public Bundle getBundle(ComponentSpecification id) { Bundle highestMatch=null; for (Bundle bundle : getBundles()) { assert bundle.getSymbolicName() != null : "ensureHasBundleSymbolicName not called during installation"; if ( ! bundle.getSymbolicName().equals(id.getName())) continue; if ( ! id.getVersionSpecification().matches(versionOf(bundle))) continue; if (highestMatch==null || versionOf(highestMatch).compareTo(versionOf(bundle))<0) highestMatch=bundle; } return highestMatch; }