@Override public boolean isEmpty() { return (min.compareTo(max) == 0) && !minInclusive && !maxInclusive; }
@Override public boolean accept(Dependency dependency) { Version version = SingleVersion.valueOf(dependency.getCoordinate().getVersion()); return version.compareTo(runtimeVersion) > 0 && version.getMajorVersion() == runtimeVersion.getMajorVersion() && "Final".equals(version.getQualifier()); } }));
/** * This method only returns true if: * * - The major version of addonApiVersion is equal to the major version of runtimeVersion AND * * - The minor version of addonApiVersion is less or equal to the minor version of runtimeVersion * * - The addonApiVersion is null * * @param runtimeVersion a version in the format x.x.x * @param addonApiVersion a version in the format x.x.x */ public static boolean isApiCompatible(Version runtimeVersion, Version addonApiVersion) { if (addonApiVersion == null || addonApiVersion.toString().length() == 0 || runtimeVersion == null || runtimeVersion.toString().length() == 0) return true; int runtimeMajorVersion = runtimeVersion.getMajorVersion(); int runtimeMinorVersion = runtimeVersion.getMinorVersion(); int addonApiMajorVersion = addonApiVersion.getMajorVersion(); int addonApiMinorVersion = addonApiVersion.getMinorVersion(); return (addonApiMajorVersion == runtimeMajorVersion && addonApiMinorVersion <= runtimeMinorVersion); }
@Override public boolean includes(Version version) { if (min != null) { int comparison = min.compareTo(version); if ((comparison == 0) && !minInclusive) { return false; } if (comparison > 0) { return false; } } if (max != null) { int comparison = max.compareTo(version); if ((comparison == 0) && !maxInclusive) { return false; } if (comparison < 0) { return false; } } return true; }
public Version matchLowestMatch(List<Version> versions) { Version matched = null; for (Version version : versions) { if (includes(version)) { if (matched == null || version.compareTo(matched) > 0) { matched = version; } } } return matched; }
/** * Return the highest {@link Version} of the given {@link List} of versions that satisfies all {@link VersionRange} * instances in this {@link MultipleVersionRange}; otherwise, return <code>null</code> if no match was found. */ public Version getHighestMatch(List<Version> versions) { Version matched = null; for (Version version : versions) { if (includes(version)) { if (matched == null || version.compareTo(matched) > 0) { matched = version; } } } return matched; }
@Override public int compareTo(AddonId other) { if (other == null) throw new IllegalArgumentException("Cannot compare against null."); int result = getName().compareTo(other.getName()); if (result == 0) result = getVersion().compareTo(other.getVersion()); if (result == 0) result = getApiVersion().compareTo(other.getApiVersion()); return result; }
@Override public boolean isMinInclusive() { VersionRange min = null; for (VersionRange range : ranges) { if (min == null || range.getMin().compareTo(min.getMin()) < 0) { min = range; } } return min == null ? false : min.isMinInclusive(); }
@Override public boolean isMaxInclusive() { VersionRange max = null; for (VersionRange range : ranges) { if (max == null || range.getMax().compareTo(max.getMax()) > 0) { max = range; } } return max == null ? false : max.isMaxInclusive(); }
@Override public Version getMax() { VersionRange max = null; for (VersionRange range : ranges) { if (max == null || range.getMax().compareTo(max.getMax()) > 0) { max = range; } } return max == null ? null : max.getMax(); }
@Override public Version getMin() { VersionRange min = null; for (VersionRange range : ranges) { if (min == null || range.getMin().compareTo(min.getMin()) < 0) { min = range; } } return min == null ? null : min.getMin(); }
if (upperVersion != null && lowerVersion != null && upperVersion.compareTo(lowerVersion) < 0)
if (range.getMin() == null || range.getMin().compareTo(upperBound) < 0)
/** * Calculate the intersection of one or more {@link VersionRange} instances, returning a single {@link VersionRange} * as the result. */ public static VersionRange intersection(Collection<VersionRange> ranges) { Assert.notNull(ranges, "Version ranges must not be null."); Assert.isTrue(ranges.size() >= 1, "Version ranges must not be empty."); Version min = null; Version max = null; boolean minInclusive = false; boolean maxInclusive = false; for (VersionRange range : ranges) { if (min == null || range.getMin().compareTo(min) > 0) { min = range.getMin(); minInclusive = range.isMinInclusive(); } if (max == null || range.getMax().compareTo(max) < 0) { max = range.getMax(); maxInclusive = range.isMaxInclusive(); } } return new DefaultVersionRange(min, minInclusive, max, maxInclusive); }
if (differentVersion.compareTo(addonVersion) < 0 && addonInfo.equals(requestedAddonInfo))
|| res1.getMin().compareTo(res2.getMax()) <= 0) || res1.getMax().compareTo(res2.getMin()) >= 0) int comparison = res1.getMin().compareTo(res2.getMin()); if (comparison < 0) int comparison = res1.getMax().compareTo(res2.getMax()); if (comparison < 0) if (min == null || max == null || min.compareTo(max) != 0)
if (id.getVersion().compareTo(maxAddonId.getVersion()) > 0 && addonAPIVersion.equals(resolver.resolveAPIVersion(id).get()))
@Override public Result execute(UIExecutionContext context) throws Exception { if (!context.getPrompt().promptBoolean( "Are you sure you want to continue? This command will delete current directories: addons, bin, lib, rules/migration-core")) { return Results.fail("Updating distribution was aborted."); } // Find the latest version. Coordinate latestDist = this.updater.getLatestReleaseOf("org.jboss.windup", "windup-distribution"); Version latestVersion = SingleVersion.valueOf(latestDist.getVersion()); Version installedVersion = currentAddon.getId().getVersion(); if (latestVersion.compareTo(installedVersion) <= 0) { return Results.fail(Util.WINDUP_BRAND_NAME_ACRONYM+" CLI is already in the most updated version."); } distUpdater.replaceWindupDirectoryWithDistribution(latestDist); return Results.success("Sucessfully updated "+Util.WINDUP_BRAND_NAME_ACRONYM+" CLI to version " + latestDist.getVersion() + ". Please restart RHAMT CLI."); }