NuxeoVersion { public String version() { StringBuilder version = new StringBuilder(); version.append(majorVersion()).append('.').append(minorVersion()); if (buildVersion() != -1) { version.append('.').append(buildVersion()); } if (hotfix() != 0) { version.append("-HF").append(String.format("%02d", hotfix())); } if (snapshot()) { version.append("-SNAPSHOT"); } return version.toString(); } 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 testVersion() { assertEquals("7.10", new NuxeoVersion(7, 10, -1, 0, false).version()); assertEquals("7.10-HF05", new NuxeoVersion(7, 10, -1, 5, false).version()); assertEquals("7.10-HF05-SNAPSHOT", new NuxeoVersion(7, 10, -1, 5, true).version()); assertEquals("7.10-SNAPSHOT", new NuxeoVersion(7, 10, -1, 0, true).version()); assertEquals("11.2.2", new NuxeoVersion(11, 2, 2, 0, false).version()); }