private int compare(Version versionA, Version versionB) { if (versionA != null && versionB != null) return versionA.compareTo(versionB); return 0; }
public int compare(Version o1, Version o2) { return o1.compareTo(o2); }
private void validateRange() { int cmp = minVersion.compareTo(maxVersion); if (!(cmp < 0 || (cmp == 0 && includeMin && includeMax))) throw new IllegalArgumentException(NLS.bind(Messages.range_min_0_is_not_less_then_range_max_1, minVersion, maxVersion)); }
/** * Returns whether the given version is included in this VersionRange. * This will depend on the minimum and maximum versions of this VersionRange * and the given version. * * @param version a version to be tested for inclusion in this VersionRange. * (may be <code>null</code>) * @return <code>true</code> if the version is include, * <code>false</code> otherwise */ public boolean isIncluded(Version version) { if (version == null) return false; if (minVersion == maxVersion) // Can only happen when both includeMin and includeMax are true return minVersion.equals(version); int minCheck = includeMin ? 0 : -1; int maxCheck = includeMax ? 0 : 1; return minVersion.compareTo(version) <= minCheck && maxVersion.compareTo(version) >= maxCheck; }
@SafeVarargs private final boolean diff(String ids, Set<IInstallableUnit>... data) { if (ids.length() != data.length) throw new IllegalArgumentException(); Set<IInstallableUnit> all = new TreeSet<>((a, b) -> { int diff = a.getId().compareTo(b.getId()); if (diff != 0) return diff; return a.getVersion().compareTo(b.getVersion()); }); for (Set<IInstallableUnit> d : data) all.addAll(d); Map<String, Integer> count = new TreeMap<>(); for (IInstallableUnit iu : all) { String out = ""; for (int i = 0; i != data.length; ++i) out += data[i].contains(iu) ? ids.charAt(i) : " "; if (out.contains(" ")) System.out.println(out + " " + iu.getId() + " " + iu.getVersion()); count.put(out, count.getOrDefault(out, 0) + 1); } for (Entry<String, Integer> e : count.entrySet()) System.out.println(e.getKey() + " = " + e.getValue()); return count.size() != 1; }
@Override public int compare(IInstallableUnit iu1, IInstallableUnit iu2) { int IdCompare = iu1.getId().compareTo(iu2.getId()); if (IdCompare != 0) return IdCompare; return iu1.getVersion().compareTo(iu2.getVersion()); } });
public int compareTo(IInstallableUnit other) { int cmp = getId().compareTo(other.getId()); if (cmp == 0) cmp = getVersion().compareTo(other.getVersion()); return cmp; }
public int compareTo(IInstallableUnit other) { int cmp = getId().compareTo(other.getId()); if (cmp == 0) cmp = getVersion().compareTo(other.getVersion()); return cmp; }
public int compare(IInstallableUnit iu1, IInstallableUnit iu2) { int IdCompare = iu1.getId().compareTo(iu2.getId()); if (IdCompare != 0) return IdCompare; return iu1.getVersion().compareTo(iu2.getVersion()); } });
@Override public int compare( IInstallableUnit u1, IInstallableUnit u2 ) { if ( u1 != null && u2 != null ) { if ( u1.getId().equalsIgnoreCase( u2.getId() ) ) { return u1.getVersion().compareTo( u2.getVersion() ); } return u1.getId().compareToIgnoreCase( u2.getId() ); } throw new IllegalArgumentException(); } }
/** * Returns a Collection<IInstallableUnit> of the installable units that contain the samples * to be installed. */ protected Collection<IInstallableUnit> findSampleIUs(URI location, SubMonitor monitor) throws ProvisionException { IMetadataRepository repository = provUI.loadMetadataRepository(location, false, monitor.split(5)); IQueryResult<IInstallableUnit> allSamples = repository.query(getSampleFeatureQuery(), monitor.split(5)); if (allSamples.isEmpty()) { throw new ProvisionException(NLS.bind(PDEUIMessages.ShowSampleAction_NoSamplesFound, location.toString())); } IInstallableUnit toInstall = null; for (Iterator<IInstallableUnit> iterator = allSamples.iterator(); iterator.hasNext();) { IInstallableUnit current = iterator.next(); if (toInstall == null || toInstall.getVersion().compareTo(current.getVersion()) < 0) { toInstall = current; } } Collection<IInstallableUnit> result = new ArrayList<>(1); result.add(toInstall); return result; }
public static AvailableIUElement[] requestToElement(Remedy remedy, boolean installMode) { if (remedy == null) return new AvailableIUElement[0]; ArrayList<AvailableIUElement> temp = new ArrayList<AvailableIUElement>(); IUElementListRoot root = new IUElementListRoot(); for (Iterator<RemedyIUDetail> iterator = remedy.getIusDetails().iterator(); iterator.hasNext();) { RemedyIUDetail iuDetail = iterator.next(); if (iuDetail.getStatus() == RemedyIUDetail.STATUS_NOT_ADDED) continue; AvailableIUElement element = new AvailableIUElement(root, iuDetail.getIu(), ProvisioningUI.getDefaultUI().getProfileId(), true); if (iuDetail.getBeingInstalledVersion() != null && iuDetail.getRequestedVersion() != null && iuDetail.getBeingInstalledVersion().compareTo(iuDetail.getRequestedVersion()) < 0 && !installMode) element.setImageOverlayId(ProvUIImages.IMG_INFO); else if (iuDetail.getStatus() == RemedyIUDetail.STATUS_REMOVED) element.setImageId(ProvUIImages.IMG_REMOVED); temp.add(element); } return temp.toArray(new AvailableIUElement[temp.size()]); }
public VersionRange intersect(VersionRange r2) { int minCompare = minVersion.compareTo(r2.getMinimum()); int maxCompare = maxVersion.compareTo(r2.getMaximum()); int minMaxCmp = resultMin.compareTo(resultMax); if (minMaxCmp < 0 || (minMaxCmp == 0 && resultMinIncluded && resultMaxIncluded)) return new VersionRange(resultMin, resultMinIncluded, resultMax, resultMaxIncluded);
} else if (swtHost.getVersion().compareTo(Version.createOSGi(3, 104, 0)) >= 0) { for (IProvidedCapability provided : iu.getProvidedCapabilities()) { if ("osgi.fragment".equals(provided.getNamespace()) && "org.eclipse.swt".equals(provided.getName())) { if (swtFragment == null || swtFragment.getVersion().compareTo(iu.getVersion()) < 0) { swtFragment = iu;
@Override public int compare(Object o1, Object o2) { BundleInfo b1 = ((TargetBundle) o1).getBundleInfo(); BundleInfo b2 = ((TargetBundle) o2).getBundleInfo(); try { Version v1 = Version.create(b1.getVersion()); Version v2 = Version.create(b2.getVersion()); return v1.compareTo(v2); } catch (IllegalArgumentException e) { // If one of the bundles has a bad version PDECore.log(e); return b1.getVersion().compareTo(b2.getVersion()); } } });
public String getIUNameWithDetail(IInstallableUnit iu) { IQueryResult<IInstallableUnit> results = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null); String text = iu.getProperty(IProfile.PROP_NAME, null); text = (text != null) ? text : iu.getId(); if (!results.isEmpty()) { boolean hasHigherVersion = false; boolean hasEqualVersion = false; for (IInstallableUnit installedIU : results.toSet()) { int compareValue = installedIU.getVersion().compareTo(iu.getVersion()); if (compareValue > 0) { hasHigherVersion = true; break; } else if (compareValue == 0) hasEqualVersion = true; } if (hasHigherVersion) return NLS.bind(ProvUIMessages.AbstractImportPage_HigherVersionInstalled, text); else if (hasEqualVersion) return NLS.bind(ProvUIMessages.AbstractImportPage_SameVersionInstalled, text); } return text; }
/** * Compute information about this IU. This computes whether or * not this IU is installed and / or updated. */ private InformationCache computeIUInformation(IInstallableUnit iu) { boolean isUpdate = false; boolean isInstalled = false; boolean isPatch = iu == null ? false : QueryUtil.isPatch(iu); if (profile != null && iu != null) { isInstalled = !profile.query(QueryUtil.createIUQuery(iu), null).isEmpty(); Iterator<IInstallableUnit> iter = profile.query(new UserVisibleRootQuery(), null).iterator(); while (iter.hasNext()) { IInstallableUnit installed = iter.next(); if (iu.getUpdateDescriptor() != null && iu.getUpdateDescriptor().isUpdateOf(installed) && (!iu.getId().equals(installed.getId()) || installed.getVersion().compareTo(iu.getVersion()) < 0)) { isUpdate = true; break; } } } return new InformationCache(iu, isUpdate, isInstalled, isPatch); }
if (result == 0) { result = iu2.getVersion().compareTo(iu1.getVersion());