@Test public void getNameTest() { Folder rootFolder = new Folder("/"); Folder aFolder = new Folder("a"); Folder abFolder = new Folder("a/b"); assertEquals("/", rootFolder.getName()); assertEquals("a", aFolder.getName()); assertEquals("b", abFolder.getName()); }
public String getName() { if (isRoot()) return ROOT_FOLDER_ID; String path = getId(); int lastSlashIndex = path.lastIndexOf("/"); if (lastSlashIndex < 0) { return path; } return path.substring(lastSlashIndex + 1); }
Folder { public String getName() { if (isRoot()) return ROOT_FOLDER_ID; String path = getId(); int lastSlashIndex = path.lastIndexOf("/"); if (lastSlashIndex < 0) { return path; } return path.substring(lastSlashIndex + 1); } }
Folder { public String getName() { if (isRoot()) return ROOT_FOLDER_ID; String path = getId(); int lastSlashIndex = path.lastIndexOf("/"); if (lastSlashIndex < 0) { return path; } return path.substring(lastSlashIndex + 1); } Folder(String id); }
Folder { public String getName() { if (isRoot()) return ROOT_FOLDER_ID; String path = getId(); int lastSlashIndex = path.lastIndexOf("/"); if (lastSlashIndex < 0) { return path; } return path.substring(lastSlashIndex + 1); } Folder(String id); String getId(); String getName(); String getParentFolderId(); static String normalizeFolderId(String id); void rename(String newId); void merge(Folder folder); void addFolderListener(FolderListener listener); void notifyRenamed(String oldFolderId); Folder getParent(); Map<String, Folder> getChildren(); void setParent(Folder parent); void addChild(Folder child); void removeChild(String folderId); void addNote(Note note); void addNotes(List<Note> newNotes); void removeNote(Note note); List<Note> getNotes(); List<Note> getNotesRecursively(); int countNotes(); boolean hasChild(); boolean isTrash(); }
Folder { public String getName() { if (isRoot()) return ROOT_FOLDER_ID; String path = getId(); int lastSlashIndex = path.lastIndexOf("/"); if (lastSlashIndex < 0) { return path; } return path.substring(lastSlashIndex + 1); } Folder(String id); String getId(); String getName(); String getParentFolderId(); static String normalizeFolderId(String id); void rename(String newId); void merge(Folder folder); void addFolderListener(FolderListener listener); void notifyRenamed(String oldFolderId); Folder getParent(); Map<String, Folder> getChildren(); void setParent(Folder parent); void addChild(Folder child); void removeChild(String folderId); void addNote(Note note); void addNotes(List<Note> newNotes); void removeNote(Note note); List<Note> getNotes(); List<Note> getNotesRecursively(); int countNotes(); boolean hasChild(); boolean isTrash(); static final String ROOT_FOLDER_ID; static final String TRASH_FOLDER_ID; static final String TRASH_FOLDER_CONFLICT_INFIX; }