@Override public Version getSpecVersion() { return SingleVersion.valueOf("2.1"); }
public static final SingleVersion valueOf(String version) { SingleVersion singleVersion = CACHE.get(version); if (singleVersion == null) { singleVersion = new SingleVersion(version); CACHE.put(version, singleVersion); } return singleVersion; }
@Override public int compareTo(Version otherVersion) { if (otherVersion == null) throw new NullPointerException("Cannot compare against null."); if (otherVersion instanceof SingleVersion) { return this.comparable.compareTo(((SingleVersion) otherVersion).comparable); } else { return compareTo(new SingleVersion(otherVersion.toString())); } }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof Version)) { return false; } return compareTo((Version) other) == 0; }
/** * @deprecated use {@link SingleVersion#valueOf(String)} instead */ @Deprecated public SingleVersion(String version) { parseVersion(version); }
public static Version getRuntimeAPIVersion() { String version = Bootstrap.class.getPackage().getImplementationVersion(); if (version != null) { return SingleVersion.valueOf(version); } return EmptyVersion.getInstance(); }
private SingleVersion getLatestCoreRulesetVersion() { Coordinate lastRelease = this.getLatestReleaseOf(RULES_GROUP_ID, RULESETS_ARTIFACT_ID); if (lastRelease == null) return null; return new SingleVersion(lastRelease.getVersion()); }
public static Version getRuntimeAPIVersion() { String version = Bootstrap.class.getPackage().getImplementationVersion(); if (version != null) { return SingleVersion.valueOf(version); } return EmptyVersion.getInstance(); }
private SingleVersion getLatestCoreRulesetVersion() { Coordinate lastRelease = this.getLatestReleaseOf(RULES_GROUP_ID, RULESETS_ARTIFACT_ID); if (lastRelease == null) return null; return new SingleVersion(lastRelease.getVersion()); }
/** * Create an {@link AddonId} from the given name, version, and API version. */ public static AddonId from(String name, String version, String apiVersion) { Assert.notNull(name, "Name cannot be null."); if (name.trim().isEmpty()) throw new IllegalArgumentException("Name cannot be empty."); Assert.notNull(version, "Version cannot be null."); if (version.trim().isEmpty()) throw new IllegalArgumentException("Version cannot be empty."); AddonId id = new AddonId(); id.name = name; id.version = SingleVersion.valueOf(version); if (apiVersion == null || apiVersion.trim().isEmpty()) id.apiVersion = EmptyVersion.getInstance(); else id.apiVersion = SingleVersion.valueOf(apiVersion); return id; }
static CoordinatePattern fromCoordinatePattern(String coordinates) { String[] parts = coordinates.split("\\s*:\\s*"); if (parts.length < 3) throw new IllegalArgumentException("Expected GAV definition format is 'GROUP_ID:ARTIFACT_ID:VERSION_OR_RANGE[:CLASSIFIER]', was: " + coordinates); CoordinateBuilder coordinate = CoordinateBuilder.create() .setGroupId(parts[0]) .setArtifactId(parts[1]); VersionRange version = null; if (parts[2].equals("*")) version = new EmptyVersionRange(); // Range - (1.0,2.0] or [1.0,2.0) etc. else if (parts[2].matches("^(\\[|\\()[^,]+(,[^,]+)?(\\]|\\))$")) version = Versions.parseMultipleVersionRange(parts[2]); else version = new SingleVersionRange(new SingleVersion(parts[2])); if (parts.length >= 4) coordinate.setClassifier(parts[3]); return new CoordinatePattern(coordinate, version); }
private SingleVersion getCurrentCoreRulesetsVersion() { Path windupRulesDir = getRulesetsDir(); Path coreRulesPomPath = windupRulesDir.resolve(RULESET_CORE_DIRECTORY + "/META-INF/maven/org.jboss.windup.rules/windup-rulesets/pom.xml"); File pomXml = coreRulesPomPath.toFile(); if (!pomXml.exists()) return null; MavenModelResource pom = (MavenModelResource) factory.create(pomXml); return SingleVersion.valueOf(pom.getCurrentModel().getVersion()); }
static CoordinatePattern fromCoordinatePattern(String coordinates) { String[] parts = coordinates.split("\\s*:\\s*"); if (parts.length < 3) throw new IllegalArgumentException("Expected GAV definition format is 'GROUP_ID:ARTIFACT_ID:VERSION_OR_RANGE[:CLASSIFIER]', was: " + coordinates); CoordinateBuilder coordinate = CoordinateBuilder.create() .setGroupId(parts[0]) .setArtifactId(parts[1]); VersionRange version = null; if (parts[2].equals("*")) version = new EmptyVersionRange(); // Range - (1.0,2.0] or [1.0,2.0) etc. else if (parts[2].matches("^(\\[|\\()[^,]+(,[^,]+)?(\\]|\\))$")) version = Versions.parseMultipleVersionRange(parts[2]); else version = new SingleVersionRange(new SingleVersion(parts[2])); if (parts.length >= 4) coordinate.setClassifier(parts[3]); return new CoordinatePattern(coordinate, version); }
private SingleVersion getCurrentCoreRulesetsVersion() { Path windupRulesDir = getRulesetsDir(); Path coreRulesPomPath = windupRulesDir.resolve(RULESET_CORE_DIRECTORY + "/META-INF/maven/org.jboss.windup.rules/windup-rulesets/pom.xml"); File pomXml = coreRulesPomPath.toFile(); if (!pomXml.exists()) return null; MavenModelResource pom = (MavenModelResource) factory.create(pomXml); return SingleVersion.valueOf(pom.getCurrentModel().getVersion()); }
static CoordinatePattern fromCoordinatePattern(String coordinates) { String[] parts = coordinates.split("\\s*:\\s*"); if (parts.length < 3) throw new IllegalArgumentException("Expected GAV definition format is 'GROUP_ID:ARTIFACT_ID:VERSION_OR_RANGE[:CLASSIFIER]', was: " + coordinates); CoordinateBuilder coordinate = CoordinateBuilder.create() .setGroupId(parts[0]) .setArtifactId(parts[1]); VersionRange version = null; if (parts[2].matches("\\*")) version = new EmptyVersionRange(); else if (parts[2].matches("^(\\[|\\()[^,]+(,?[^,]+)+(\\]|\\))$")) version = Versions.parseMultipleVersionRange(parts[2]); else version = new SingleVersionRange(new SingleVersion(parts[2])); if (parts.length >= 4) coordinate.setClassifier(parts[3]); return new CoordinatePattern(coordinate, version); }
public static boolean isSkipped(Coordinate coordinate) { for (Entry<Coordinate, VersionRange> entry : map.entrySet()) { Coordinate pattern = entry.getKey(); VersionRange range = entry.getValue(); if (isPatternMatch(pattern.getGroupId(), coordinate.getGroupId()) && isPatternMatch(pattern.getArtifactId(), coordinate.getArtifactId()) && isPatternMatch(pattern.getClassifier(), coordinate.getClassifier())) { if (range.isEmpty() || range.includes(new SingleVersion(coordinate.getVersion()))) return true; } } return false; }
/** * Returns the Implementation version for the given {@link Class} * * @param type the {@link Class} with the corresponding package * @return {@link Version} representation from the {@link Package#getImplementationVersion()} returned from * {@link Class#getPackage()} */ public static Version getImplementationVersionFor(Class<?> type) { Assert.notNull(type, "Type must not be null."); final Version result; Package pkg = type.getPackage(); if (pkg == null) { result = EmptyVersion.getInstance(); } else { String version = pkg.getImplementationVersion(); if (Strings.isNullOrEmpty(version)) { result = EmptyVersion.getInstance(); } else { result = SingleVersion.valueOf(version); } } return result; }
public static boolean isSkipped(Coordinate coordinate) { for (Entry<Coordinate, VersionRange> entry : map.entrySet()) { Coordinate pattern = entry.getKey(); VersionRange range = entry.getValue(); if (isPatternMatch(pattern.getGroupId(), coordinate.getGroupId()) && isPatternMatch(pattern.getArtifactId(), coordinate.getArtifactId()) && isPatternMatch(pattern.getClassifier(), coordinate.getClassifier())) { if (range.isEmpty() || range.includes(new SingleVersion(coordinate.getVersion()))) return true; } } return false; }
/** * Returns the Specification version for the given {@link Class} * * @param type the {@link Class} with the corresponding package * @return {@link Version} representation from the {@link Package#getSpecificationVersion()} returned from * {@link Class#getPackage()} */ public static Version getSpecificationVersionFor(Class<?> type) { Assert.notNull(type, "Type must not be null."); final Version result; Package pkg = type.getPackage(); if (pkg == null) { result = EmptyVersion.getInstance(); } else { String version = pkg.getSpecificationVersion(); if (Strings.isNullOrEmpty(version)) { result = EmptyVersion.getInstance(); } else { result = SingleVersion.valueOf(version); } } return result; }