ModuleId implements Comparable<ModuleId> { public String getLatest(Collection<String> l) { ModuleId latestModule = this; for (String curId : l) { ModuleId curModule = new ModuleId(curId); if (product.equals(curModule.getProduct()) && curModule.compareTo(latestModule) > 0) { latestModule = curModule; } } return latestModule.getId(); } ModuleId(String s); String getId(); SemVer getSemVer(); boolean hasSemVer(); boolean hasNpmSnapshot(); boolean hasPreRelease(); String getProduct(); @Override int compareTo(ModuleId other); @Override boolean equals(Object that); @Override int hashCode(); @Override String toString(); static int compare(String i1, String i2); String getLatest(Collection<String> l); boolean hasPrefix(ModuleId other);  }
@Test public void testLatest() { ModuleId module_1 = new ModuleId("module-1"); List<String> versionsL = new LinkedList<>(); versionsL.add("module-1.0"); versionsL.add("module-1.0-2"); versionsL.add("module-0.9"); versionsL.add("other-1.1"); versionsL.add("other-0.9"); assertEquals("module-1.0", module_1.getLatest(versionsL)); assertEquals("module-1", module_1.getLatest(new LinkedList<>())); }