private void add(final TreeEntry entry) { String type = entry.getType(); String path = entry.getPath(); if (TextUtils.isEmpty(path)) return; if (TYPE_BLOB.equals(type)) { String[] segments = path.split("/"); if (segments.length > 1) { Folder folder = folders.get(segments[0]); if (folder != null) folder.addFile(entry, segments, 1); } else if (segments.length == 1) { Entry file = new Entry(entry, this); files.put(file.name, file); } } else if (TYPE_TREE.equals(type)) { String[] segments = path.split("/"); if (segments.length > 1) { Folder folder = folders.get(segments[0]); if (folder != null) folder.addFolder(entry, segments, 1); } else if (segments.length == 1) { Folder folder = new Folder(entry, this); folders.put(folder.name, folder); } } }
private Entry(TreeEntry entry, Folder parent) { this.entry = entry; this.parent = parent; this.name = CommitUtils.getName(entry.getPath()); }