/** * A version 6.163.20 will be returned as a number 163.020. The major * version can normally be inferred. As long as the micro version stays * below 1000 these numbers sort like Version. */ private static double getVersionAsNumber(Version version) { return version.getMinor() + version.getMicro() / 1000.0; }
/** * Returns the string representation of this version identifier as major.minor.micro.qualifier, * omitting .qualifier if qualifier empty or unspecified * <p> * This string form is part of the API of Version and will never change. */ public String toFullString() { StringBuilder b = new StringBuilder(); b.append(getMajor()); b.append("."); b.append(getMinor()); b.append("."); b.append(getMicro()); if (! qualifier.isEmpty()) { b.append("."); b.append(qualifier); } return b.toString(); }
private String toStringValue() { StringBuilder b = new StringBuilder(); if (! qualifier.isEmpty()) { b.append(getMajor()); b.append("."); b.append(getMinor()); b.append("."); b.append(getMicro()); b.append("."); b.append(qualifier); } else if (getMicro() != 0) { b.append(getMajor()); b.append("."); b.append(getMinor()); b.append("."); b.append(getMicro()); } else if (getMinor() != 0) { b.append(getMajor()); b.append("."); b.append(getMinor()); } else if (getMajor() != 0) { b.append(getMajor()); } return b.toString(); }
/** Creates a version specification that only matches this version */ public VersionSpecification toSpecification() { if (this == emptyVersion) return VersionSpecification.emptyVersionSpecification; else { return new VersionSpecification(getMajor(), getMinor(), getMicro(), 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; } }