@Test public void compareTo_differentRevisionNumber() { final VersionNumber version1 = new VersionNumber(Arrays.asList("11", "0", "0", "1")); final VersionNumber version2 = new VersionNumber(Arrays.asList("11", "0", "0")); assertThat(version1.compareTo(version2)).isEqualTo(1); assertThat(version2.compareTo(version1)).isEqualTo(-1); }
@Override public int compareTo(@Nullable final ReadableVersionNumber other) { int result = 0; if (other == null) { result = -1; } else { Check.notNull(other.getGroups(), "other.getGroups()"); final int length = groups.size() < other.getGroups().size() ? groups.size() : other.getGroups().size(); final NaturalOrderComparator comparator = new NaturalOrderComparator(); result = comparator.compare(toVersionString(groups.subList(0, length)), toVersionString(other.getGroups().subList(0, length))); if (result == 0) { result = groups.size() > other.getGroups().size() ? 1 : groups.size() < other.getGroups().size() ? -1 : 0; } if (result == 0) { result = extension.compareTo(other.getExtension()); } if (result == 0) { result = comparator.compare(toVersionString(), other.toVersionString()); } } return result; }
VersionNumber implements ReadableVersionNumber, Serializable { @Override public int compareTo(@Nullable final ReadableVersionNumber other) { int result = 0; if (other == null) { result = -1; } else { Check.notNull(other.getGroups(), "other.getGroups()"); final int length = groups.size() < other.getGroups().size() ? groups.size() : other.getGroups().size(); final NaturalOrderComparator comparator = new NaturalOrderComparator(); result = comparator.compare(toVersionString(groups.subList(0, length)), toVersionString(other.getGroups().subList(0, length))); if (result == 0) { result = groups.size() > other.getGroups().size() ? 1 : groups.size() < other.getGroups().size() ? -1 : 0; } if (result == 0) { result = extension.compareTo(other.getExtension()); } if (result == 0) { result = comparator.compare(toVersionString(), other.toVersionString()); } } return result; } }
VersionNumber implements ReadableVersionNumber, Serializable { @Override public int compareTo(@Nullable final ReadableVersionNumber other) { int result = 0; if (other == null) { result = -1; } else { Check.notNull(other.getGroups(), "other.getGroups()"); final int length = groups.size() < other.getGroups().size() ? groups.size() : other.getGroups().size(); final NaturalOrderComparator comparator = new NaturalOrderComparator(); result = comparator.compare(toVersionString(groups.subList(0, length)), toVersionString(other.getGroups().subList(0, length))); if (result == 0) { result = groups.size() > other.getGroups().size() ? 1 : groups.size() < other.getGroups().size() ? -1 : 0; } if (result == 0) { result = extension.compareTo(other.getExtension()); } if (result == 0) { result = comparator.compare(toVersionString(), other.toVersionString()); } } return result; } VersionNumber(@Nonnull final List<String> groups);  VersionNumber(@Nonnull final List<String> groups, @Nonnull final String extension);  VersionNumber(@Nonnull final String major);  VersionNumber(@Nonnull final String major, @Nonnull final String minor);  VersionNumber(@Nonnull final String major, @Nonnull final String minor, @Nonnull final String bugfix);  VersionNumber(@Nonnull final String major, @Nonnull final String minor, @Nonnull final String bugfix,
			@Nonnull final String extension); }
VersionNumber implements ReadableVersionNumber, Serializable { @Override public int compareTo(@Nullable final ReadableVersionNumber other) { int result = 0; if (other == null) { result = -1; } else { Check.notNull(other.getGroups(), "other.getGroups()"); final int length = groups.size() < other.getGroups().size() ? groups.size() : other.getGroups().size(); final NaturalOrderComparator comparator = new NaturalOrderComparator(); result = comparator.compare(toVersionString(groups.subList(0, length)), toVersionString(other.getGroups().subList(0, length))); if (result == 0) { result = groups.size() > other.getGroups().size() ? 1 : groups.size() < other.getGroups().size() ? -1 : 0; } if (result == 0) { result = extension.compareTo(other.getExtension()); } if (result == 0) { result = comparator.compare(toVersionString(), other.toVersionString()); } } return result; } VersionNumber(@Nonnull final List<String> groups);  VersionNumber(@Nonnull final List<String> groups, @Nonnull final String extension);  VersionNumber(@Nonnull final String major);  VersionNumber(@Nonnull final String major, @Nonnull final String minor);  VersionNumber(@Nonnull final String major, @Nonnull final String minor, @Nonnull final String bugfix);  VersionNumber(@Nonnull final String major, @Nonnull final String minor, @Nonnull final String bugfix,
			@Nonnull final String extension); static VersionNumber parseLastVersionNumber(@Nonnull final String text); static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent); static VersionNumber parseVersion(@Nonnull final String version); static List<String> replaceNullValueWithEmptyGroup(@Nonnull final List<String> groups); @Override int compareTo(@Nullable final ReadableVersionNumber other); @Override boolean equals(final Object obj); @Override String getBugfix(); @Override String getExtension(); @Override List<String> getGroups(); @Override String getMajor(); @Override String getMinor(); @Override int hashCode(); @Nonnull @Override String toString(); @Nonnull @Override String toVersionString(); }
VersionNumber implements ReadableVersionNumber, Serializable { @Override public int compareTo(@Nullable final ReadableVersionNumber other) { int result = 0; if (other == null) { result = -1; } else { Check.notNull(other.getGroups(), "other.getGroups()"); final int length = groups.size() < other.getGroups().size() ? groups.size() : other.getGroups().size(); final NaturalOrderComparator comparator = new NaturalOrderComparator(); result = comparator.compare(toVersionString(groups.subList(0, length)), toVersionString(other.getGroups().subList(0, length))); if (result == 0) { result = groups.size() > other.getGroups().size() ? 1 : groups.size() < other.getGroups().size() ? -1 : 0; } if (result == 0) { result = extension.compareTo(other.getExtension()); } if (result == 0) { result = comparator.compare(toVersionString(), other.toVersionString()); } } return result; } VersionNumber(@Nonnull final List<String> groups);  VersionNumber(@Nonnull final List<String> groups, @Nonnull final String extension);  VersionNumber(@Nonnull final String major);  VersionNumber(@Nonnull final String major, @Nonnull final String minor);  VersionNumber(@Nonnull final String major, @Nonnull final String minor, @Nonnull final String bugfix);  VersionNumber(@Nonnull final String major, @Nonnull final String minor, @Nonnull final String bugfix,
			@Nonnull final String extension); static VersionNumber parseLastVersionNumber(@Nonnull final String text); static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent); static VersionNumber parseVersion(@Nonnull final String version); static List<String> replaceNullValueWithEmptyGroup(@Nonnull final List<String> groups); @Override int compareTo(@Nullable final ReadableVersionNumber other); @Override boolean equals(final Object obj); @Override String getBugfix(); @Override String getExtension(); @Override List<String> getGroups(); @Override String getMajor(); @Override String getMinor(); @Override int hashCode(); @Nonnull @Override String toString(); @Nonnull @Override String toVersionString(); static final String EMPTY_EXTENSION; static final String EMPTY_GROUP; static final VersionNumber UNKNOWN; }