NuxeoVersion { public static NuxeoVersion parse(String version) { Matcher matcher = NUXEO_VERSION_PATTERN.matcher(version); if (!matcher.matches()) { throw new NuxeoClientException( "Input version=" + version + " doesn't represent a valid Nuxeo server version"); } int majorVersion = Integer.parseInt(matcher.group(1)); int minorVersion = Integer.parseInt(matcher.group(2)); int buildVersion = -1; if (matcher.group(3) != null) { buildVersion = Integer.parseInt(matcher.group(3)); } int hotfix = 0; if (matcher.group(4) != null) { hotfix = Integer.parseInt(matcher.group(4)); } boolean snaphot = matcher.group(5) != null; return new NuxeoVersion(majorVersion, minorVersion, buildVersion, hotfix, snaphot); } protected  NuxeoVersion(int majorVersion, int minorVersion, int buildVersion, int hotfix, boolean snapshot); String version(); int majorVersion(); int minorVersion(); int buildVersion(); int hotfix(); boolean snapshot(); boolean equals(String version); boolean equals(NuxeoVersion version); @Override int hashCode(); @Override boolean equals(Object version); @Override String toString(); NuxeoVersion hotfix(int hotfix); boolean isGreaterThan(String version); boolean isGreaterThan(NuxeoVersion version); static NuxeoVersion parse(String version); static final NuxeoVersion LTS_7_10; static final NuxeoVersion LTS_8_10; static final NuxeoVersion LTS_9_10; static final NuxeoVersion LTS_10_10; }
@Test public void testParseVersion() { assertVersion(NuxeoVersion.parse("7.10"), 7, 10, -1, 0, false); assertVersion(NuxeoVersion.parse("7.10-HF05"), 7, 10, -1, 5, false); assertVersion(NuxeoVersion.parse("7.10-HF05-SNAPSHOT"), 7, 10, -1, 5, true); assertVersion(NuxeoVersion.parse("7.10-SNAPSHOT"), 7, 10, -1, 0, true); assertVersion(NuxeoVersion.parse("7.10-I20170818_1955"), 7, 10, -1, 0, false); assertVersion(NuxeoVersion.parse("11.2.2"), 11, 2, 2, 0, false); }