@Test public void shouldCreateCloneFromTreeStructure() { KeePassFile keePassFile = createTreeStructure(); KeePassFile clonedKeePassFile = new GroupZipper(keePassFile).cloneKeePassFile(); compareKeePassFiles(keePassFile, clonedKeePassFile); }
public KeePassFile cloneKeePassFile() { Iterator<Group> iter = iterator(); while(iter.hasNext()) { Group group = iter.next(); Group clonedGroup = cloneGroup(group); replace(clonedGroup); } return close(); }
GroupZipper { public KeePassFile cloneKeePassFile() { Iterator<Group> iter = iterator(); while(iter.hasNext()) { Group group = iter.next(); Group clonedGroup = cloneGroup(group); replace(clonedGroup); } return close(); } }
GroupZipper { public KeePassFile cloneKeePassFile() { Iterator<Group> iter = iterator(); while(iter.hasNext()) { Group group = iter.next(); Group clonedGroup = cloneGroup(group); replace(clonedGroup); } return close(); } GroupZipper(KeePassFile keePassFile); private  GroupZipper(GroupZipper parent, Group group, int index); }
GroupZipper { public KeePassFile cloneKeePassFile() { Iterator<Group> iter = iterator(); while(iter.hasNext()) { Group group = iter.next(); Group clonedGroup = cloneGroup(group); replace(clonedGroup); } return close(); } GroupZipper(KeePassFile keePassFile); private  GroupZipper(GroupZipper parent, Group group, int index); boolean canDown(); GroupZipper down(); boolean canUp(); GroupZipper up(); boolean canRight(); GroupZipper right(); boolean canLeft(); GroupZipper left(); Group getNode(); GroupZipper replace(Group group); KeePassFile close(); KeePassFile cloneKeePassFile(); Group getRoot(); GroupZipper replaceMeta(Meta meta); @Override String toString(); Iterator<Group> iterator(); }
GroupZipper { public KeePassFile cloneKeePassFile() { Iterator<Group> iter = iterator(); while(iter.hasNext()) { Group group = iter.next(); Group clonedGroup = cloneGroup(group); replace(clonedGroup); } return close(); } GroupZipper(KeePassFile keePassFile); private  GroupZipper(GroupZipper parent, Group group, int index); boolean canDown(); GroupZipper down(); boolean canUp(); GroupZipper up(); boolean canRight(); GroupZipper right(); boolean canLeft(); GroupZipper left(); Group getNode(); GroupZipper replace(Group group); KeePassFile close(); KeePassFile cloneKeePassFile(); Group getRoot(); GroupZipper replaceMeta(Meta meta); @Override String toString(); Iterator<Group> iterator();  }