return null;
} else if (results.size() == 1) {
return results.get(0);
}
PackageVersion latest = results.get(0);
String packageTypeName = latest.getGeneralPackage().getPackageType().getName();
Comparator<PackageVersion> versionComparator = null;
try {
PackageTypeBehavior behavior = ContentManagerHelper.getPackageTypeBehavior(packageTypeName);
versionComparator = behavior.getPackageVersionComparator(packageTypeName);
} catch (Exception e) {
log.error("Could not get the package type behavior for package type '" + packageTypeName + "'. This should not happen.", e);
}
if (versionComparator == null) {
versionComparator = PackageVersion.DEFAULT_COMPARATOR;
}
Iterator<PackageVersion> it = results.iterator();
it.next(); //skip the first element, we don't have to compare it with itself
while(it.hasNext()) {
PackageVersion current = it.next();
if (versionComparator.compare(latest, current) < 0) {
latest = current;
}
}