class DropboxListService implements ListService {

    @Override
    public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
        try {
            final AttributedList<Path> children = new AttributedList<>();
            ListFolderResult result;
            final DbxRawClientV2 client;
            this.parse(directory, listener, children, result = new DbxUserFilesRequests(session.getClient(directory)).listFolder(containerService.getKey(directory)));
            // If true, then there are more entries available. Pass the cursor to list_folder/continue to retrieve the rest.
            while(result.getHasMore()) {
                this.parse(directory, listener, children, result = new DbxUserFilesRequests(session.getClient(directory)).listFolderContinue(result.getCursor()));
            }
            return children;
        }
        catch(DbxException e) {
            throw new DropboxExceptionMappingService().map("Listing directory {0} failed", e, directory);
        }
    }

    public  DropboxListService(final DropboxSession session);

}