/** * Must be called on construction after the component values are set * * @throws IllegalArgumentException If the numerical components are negative * or the qualifier string is invalid. */ private void initialize() { stringValue = toStringValue(major, minor, micro, qualifier); ensureUnspecifiedOnlyToTheRight(major, minor, micro, qualifier); if (major!=null && major < 0) throw new IllegalArgumentException("Negative major in " + this); if (minor!=null && minor < 0) throw new IllegalArgumentException("Negative minor in " + this); if (micro!=null && micro < 0) throw new IllegalArgumentException("Negative micro in " + this); String q = getQualifier(); for (int i = 0; i < q.length(); i++) { if ( !Character.isLetterOrDigit(q.charAt(i)) ) throw new IllegalArgumentException("Invalid qualifier in " + this + ": Invalid character at position " + i + " in qualifier"); } }
/** * Returns the lowest possible Version object that matches this spec **/ public Version lowestMatchingVersion() { return new Version(getMajor(), getMinor(), getMicro(), getQualifier()); }
if (result != 0) return result; return getQualifier().compareTo(other.getQualifier());
/** * Returns true if the given version matches this specification. * It matches if all the numeric components specified are the same * as in the version, and both qualifiers are either null or set * to the same value. I.e, a version which includes a qualifier * will only match exactly and will never return true from a * request for an unspecified qualifier. */ public boolean matches(Version version) { if (matches(this.major, version.getMajor()) && matches(this.minor, version.getMinor()) && matches(this.micro, version.getMicro())) { return (version.getQualifier().equals(this.getQualifier())); } else { return false; } }