Version implements Immutable, Comparable<Version>, Serializable { static List<Integer> normalizedList(List<Integer> list) { ListIterator<Integer> iterator = list.listIterator(list.size()); int lastNonZeroIndex = -1; while (iterator.hasPrevious()) { if (iterator.previous() != 0) { lastNonZeroIndex = iterator.nextIndex(); break; } } return lastNonZeroIndex == -1 ? ImmutableList.of(0) : list.subList(0, lastNonZeroIndex + 1); } private  Version(List<Integer> numbers, List<?> prerelease, List<?> build, String original);  Version(List<Integer> numbers, List<?> prerelease, List<?> build); @Override boolean equals(Object otherObject); @Override int hashCode(); static Version latest(); static Version valueOf(String versionString); @Override int compareTo(Version other); ImmutableList<Integer> getNumbers(); ImmutableList<Object> getPrerelease(); ImmutableList<Object> getBuild(); boolean isWellFormed(); @Override String toString(); String toNormalizedString();  }
@Test public void testNormalizeList() { Assert.assertEquals(Version.normalizedList(Arrays.asList(0)), Collections.singletonList(0)); Assert.assertEquals(Version.normalizedList(Arrays.asList(0, 0)), Collections.singletonList(0)); Assert.assertEquals(Version.normalizedList(Arrays.asList(23, 0, 4)), Arrays.asList(23, 0, 4)); Assert.assertEquals(Version.normalizedList(Arrays.asList(23, 0, 0, 0)), Arrays.asList(23)); Assert.assertEquals(Version.normalizedList(Arrays.asList(2, 1, 0)), Arrays.asList(2, 1)); }