Version implements Comparable<Version> { @Override public String toString() { StringBuilder result = new StringBuilder().append(major).append('.').append(minor); if (isMiscAvailable()) result.append('.').append(misc); return result.toString(); } Version(String version);  Version(final int major, final int minor);  Version(final int major, final int minor, final int misc); static Version parseVersion(String version); static Version valueOf(String version); int getMajor(); int getMinor(); Integer getMisc(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); boolean isMiscAvailable(); int compareTo(Version that);  }
@Test public void toString_shouldOutputCorrectly() { String versionStr = "1.2.3"; Version version = new Version(versionStr); assertThat(version.toString(), is(versionStr)); versionStr = "1.2"; version = new Version(versionStr); assertThat(version.toString(), is(versionStr)); }