@Test public void testBack() { Navigation n = new Navigation(); assertNull(n.back()); n.add(new Path("a", EnumSet.of(Path.Type.directory))); n.add(new Path("b", EnumSet.of(Path.Type.directory))); assertEquals("a", n.back().getName()); assertEquals("b", n.forward().getName()); }
public Path back() { int size = back.size(); if(size > 1) { forward.add(back.get(size - 1)); Path p = back.get(size - 2); back.remove(size - 1); back.remove(size - 2); return p; } else if(1 == size) { forward.add(back.get(size - 1)); return back.get(size - 1); } return null; }
Navigation { public Path back() { int size = back.size(); if(size > 1) { forward.add(back.get(size - 1)); Path p = back.get(size - 2); back.remove(size - 1); back.remove(size - 2); return p; } else if(1 == size) { forward.add(back.get(size - 1)); return back.get(size - 1); } return null; } }
Navigation { public Path back() { int size = back.size(); if(size > 1) { forward.add(back.get(size - 1)); Path p = back.get(size - 2); back.remove(size - 1); back.remove(size - 2); return p; } else if(1 == size) { forward.add(back.get(size - 1)); return back.get(size - 1); } return null; }  }
Navigation { public Path back() { int size = back.size(); if(size > 1) { forward.add(back.get(size - 1)); Path p = back.get(size - 2); back.remove(size - 1); back.remove(size - 2); return p; } else if(1 == size) { forward.add(back.get(size - 1)); return back.get(size - 1); } return null; }  void add(final Path p); Path back(); Path forward(); List<Path> getBack(); List<Path> getForward(); void clear(); }
Navigation { public Path back() { int size = back.size(); if(size > 1) { forward.add(back.get(size - 1)); Path p = back.get(size - 2); back.remove(size - 1); back.remove(size - 2); return p; } else if(1 == size) { forward.add(back.get(size - 1)); return back.get(size - 1); } return null; }  void add(final Path p); Path back(); Path forward(); List<Path> getBack(); List<Path> getForward(); void clear();  }