@Test public void testRetrievingVersion() { Changelog changelog = new Changelog(); Version version = changelog.getLastAdded(); Version lookup = changelog.getVersion(version.getId()); assertEquals(version, lookup); }
public Version getVersion(String versionId) { checkArgument(!isNullOrEmpty(versionId), "You must specify a 'versionId'."); List<Version> toVisit = Lists.newArrayList(root); Set<Version> visited = Sets.newHashSet(); while (!toVisit.isEmpty()) { Version version = toVisit.remove(0); if (visited.contains(version)) { continue; } if (version.getId().equals(versionId)) { return version; } visited.add(version); if (version.getChild() != null) { toVisit.add(version.getChild()); } } throw new IllegalArgumentException("No version found with id: '" + versionId + "'."); }
Changelog { public Version getVersion(String versionId) { checkArgument(!isNullOrEmpty(versionId), "You must specify a 'versionId'."); List<Version> toVisit = Lists.newArrayList(root); Set<Version> visited = Sets.newHashSet(); while (!toVisit.isEmpty()) { Version version = toVisit.remove(0); if (visited.contains(version)) { continue; } if (version.getId().equals(versionId)) { return version; } visited.add(version); if (version.getChild() != null) { toVisit.add(version.getChild()); } } throw new IllegalArgumentException("No version found with id: '" + versionId + "'."); } }
Changelog { public Version getVersion(String versionId) { checkArgument(!isNullOrEmpty(versionId), "You must specify a 'versionId'."); List<Version> toVisit = Lists.newArrayList(root); Set<Version> visited = Sets.newHashSet(); while (!toVisit.isEmpty()) { Version version = toVisit.remove(0); if (visited.contains(version)) { continue; } if (version.getId().equals(versionId)) { return version; } visited.add(version); if (version.getChild() != null) { toVisit.add(version.getChild()); } } throw new IllegalArgumentException("No version found with id: '" + versionId + "'."); } Changelog();  Changelog(String rootVersionId);  Changelog(String rootVersionId, ChangeSet changeSet); }
Changelog { public Version getVersion(String versionId) { checkArgument(!isNullOrEmpty(versionId), "You must specify a 'versionId'."); List<Version> toVisit = Lists.newArrayList(root); Set<Version> visited = Sets.newHashSet(); while (!toVisit.isEmpty()) { Version version = toVisit.remove(0); if (visited.contains(version)) { continue; } if (version.getId().equals(versionId)) { return version; } visited.add(version); if (version.getChild() != null) { toVisit.add(version.getChild()); } } throw new IllegalArgumentException("No version found with id: '" + versionId + "'."); } Changelog();  Changelog(String rootVersionId);  Changelog(String rootVersionId, ChangeSet changeSet); Changelog addChangeSet(String id, String author, Collection<Operation> operations); Changelog addChangeSet(String id, String author, Operation... operations); Changelog addChangeSet(String id, String author, String description, Collection<Operation> operations); Changelog addChangeSet(String id, String author, String description, Operation... operations); Changelog addChangeSet(ChangeSet changeSet, Collection<Operation> operations); Changelog addChangeSet(ChangeSet changeSet, Operation... operations); Changelog addChangeSet(Version appendTo, ChangeSet changeSet, Operation... operations); Changelog addChangeSet(Version appendTo, ChangeSet changeSet, Collection<Operation> operations); Version getVersion(String versionId); }
Changelog { public Version getVersion(String versionId) { checkArgument(!isNullOrEmpty(versionId), "You must specify a 'versionId'."); List<Version> toVisit = Lists.newArrayList(root); Set<Version> visited = Sets.newHashSet(); while (!toVisit.isEmpty()) { Version version = toVisit.remove(0); if (visited.contains(version)) { continue; } if (version.getId().equals(versionId)) { return version; } visited.add(version); if (version.getChild() != null) { toVisit.add(version.getChild()); } } throw new IllegalArgumentException("No version found with id: '" + versionId + "'."); } Changelog();  Changelog(String rootVersionId);  Changelog(String rootVersionId, ChangeSet changeSet); Changelog addChangeSet(String id, String author, Collection<Operation> operations); Changelog addChangeSet(String id, String author, Operation... operations); Changelog addChangeSet(String id, String author, String description, Collection<Operation> operations); Changelog addChangeSet(String id, String author, String description, Operation... operations); Changelog addChangeSet(ChangeSet changeSet, Collection<Operation> operations); Changelog addChangeSet(ChangeSet changeSet, Operation... operations); Changelog addChangeSet(Version appendTo, ChangeSet changeSet, Operation... operations); Changelog addChangeSet(Version appendTo, ChangeSet changeSet, Collection<Operation> operations); Version getVersion(String versionId);  }