项目:molgenis
文件:MenuManagerController.java
@GetMapping
public String init(Model model)
{
List<UiMenuItem> menus = new TreeTraverser<UiMenuItem>()
{
@Override
public Iterable<UiMenuItem> children(UiMenuItem root)
{
if (root.getType() == UiMenuItemType.MENU)
{
UiMenu menu = (UiMenu) root;
return Iterables.filter(menu.getItems(),molgenisUiMenuItem -> molgenisUiMenuItem.getType() == UiMenuItemType.MENU);
}
else return Collections.emptyList();
}
}.preOrderTraversal(molgenisUi.getMenu()).toList();
List<Plugin> plugins = Lists.newArrayList(menuManagerService.getPlugins());
plugins.sort(Comparator.comparing(Plugin::getId));
model.addAttribute("menus",menus);
model.addAttribute("plugins",plugins);
model.addAttribute("molgenis_ui",molgenisUi);
return "view-menumanager";
}
项目:greenpepper
文件:FileSystemRepositoryTest.java
@SuppressWarnings("unchecked")
public void testWeCanGetTheSpecificationHierarchy() throws Exception
{
List<String> names = Arrays.asList("specs","specs/dira","specs/dira/spec1.html","specs/dira/subdira","specs/dira/subdira/spec2.html","specs/dira/subdira/spec4.html","specs/dirb","specs/dirb/spec5.html","spec3.html");
File hierarchy = new File(FileUtils.toFile(getClass().getResource(".")),"testWeCanGetTheSpecificationHierarchy");
hierarchy.mkdirs();
createSpecificationHierarchyFiles(hierarchy,names);
FileSystemRepository fileSystemRepository = new FileSystemRepository(hierarchy);
DocumentNode tree = fileSystemRepository.getSpecificationsHierarchy("TOTO","TATA");
TreeTraverser<List<?>> traverser = new TreeTraverser<List<?>>() {
@Override
public Iterable<List<?>> children(List<?> root) {
return ((Hashtable<String,List<?>>)root.get(3)).values();
}
};
Iterator<DocumentNode> listsIter = DocumentNode.traverser.preOrderTraversal(tree).iterator();
assertEquals("testWeCanGetTheSpecificationHierarchy",listsIter.next().getTitle());
assertEquals("/specs",listsIter.next().getTitle());
assertEquals("/specs/dirb",listsIter.next().getTitle());
assertEquals("/specs/dirb/spec5.html",listsIter.next().getTitle());
assertEquals("/specs/dira",listsIter.next().getTitle());
assertEquals("/specs/dira/subdira",listsIter.next().getTitle());
assertEquals("/specs/dira/subdira/spec2.html",listsIter.next().getTitle());
assertEquals("/specs/dira/subdira/spec4.html",listsIter.next().getTitle());
assertEquals("/specs/dira/spec1.html",listsIter.next().getTitle());
assertEquals("/spec3.html",listsIter.next().getTitle());
}
项目:dex-method-counts
文件:DexMethodCounts.java
private static <T> TreeTraverser<T> treeTraverserOf(Function<T,Iterable<T>> childrenFunction) {
return new TreeTraverser<T>() {
@Override
public Iterable<T> children(T root) {
return childrenFunction.apply(root);
}
};
}
项目:mapper
文件:Composites.java
public static <CompositeT extends Composite<CompositeT>> Iterable<CompositeT> preOrderTraversal(CompositeT root) {
return TreeTraverser.using(new com.google.common.base.Function<CompositeT,Iterable<CompositeT>>() {
@Override
public Iterable<CompositeT> apply(CompositeT input) {
return input == null ? Collections.<CompositeT>emptyList() : input.children();
}
}).preOrderTraversal(root);
}
项目:rainbow
文件:AstUtils.java
public static Stream<Node> preOrder(Node node)
{
return TreeTraverser.using((Node n) -> unmodifiableIterable(n.getChildren()))
.preOrderTraversal(requireNonNull(node,"node is null"))
.stream();
}
项目:streems
文件:GuavaTraversal.java
GuavaTraversal(final TreeTraverser<E> traverser)
{
this.traverser = traverser;
}
项目:factoryfx
文件:FactoryBase.java
public Iterable<FactoryBase<?,V>> breadthFirstTraversalFromRoot(){
factory.prepareIterationRunFromRoot();
final TreeTraverser<FactoryBase<?,V>> factoryTraverser = new FactoryTreeTraverser<>();
return factoryTraverser.breadthFirstTraversal(factory);
}
项目:factoryfx
文件:FactoryBase.java
public Iterable<FactoryBase<?,V>> postOrderTraversalFromRoot(){
factory.prepareIterationRunFromRoot();
final TreeTraverser<FactoryBase<?,V>> factoryTraverser = new FactoryTreeTraverser<>();
return factoryTraverser.postOrderTraversal(factory);
}
项目:louie
文件:Tree.java
public TreeTraverser<TreeNode<K,V>> getTraverser() {
return new Traverser();
}
项目:streems
文件:GuavaStreems.java
/**
* Return a stream of nodes in a requested order
*
* @param root the root of the tree
* @param traverser the {@link TreeTraverser} instance
* @param traversal the requested traversal order
* @param <E> type of the nodes in the tree
* @return a stream of the nodes in the requested traversal order
*/
public static <E> Stream<E> traverse(final E root,final TreeTraverser<E> traverser,final Traversal traversal)
{
final GuavaTraversal<E> gt = new GuavaTraversal<>(traverser);
final Iterable<E> iterable = gt.forTraversal(traversal).apply(root);
return StreamSupport.stream(iterable.spliterator(),false);
}
项目:guava-mock
文件:MoreFiles.java
/**
* Returns a {@link TreeTraverser} for traversing a directory tree. The returned traverser
* attempts to avoid following symbolic links to directories. However,the traverser cannot
* guarantee that it will not follow symbolic links to directories as it is possible for a
* directory to be replaced with a symbolic link between checking if the file is a directory and
* actually reading the contents of that directory.
*
* <p>Note that if the {@link Path} passed to one of the traversal methods does not exist,no
* exception will be thrown and the returned {@link Iterable} will contain a single element: that
* path.
*
* <p>{@link DirectoryIteratorException} may be thrown when iterating {@link Iterable} instances
* created by this traverser if an {@link IOException} is thrown by a call to
* {@link #listFiles(Path)}.
*/
public static TreeTraverser<Path> directoryTreeTraverser() {
return DirectoryTreeTraverser.INSTANCE;
}
项目:guava-mock
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,and as such there is no
* way to ensure that a symbolic link to a directory is not followed when traversing the tree. In
* this case,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:googles-monorepo-demo
文件:MoreFiles.java
/**
* Returns a {@link TreeTraverser} for traversing a directory tree. The returned traverser
* attempts to avoid following symbolic links to directories. However,no
* exception will be thrown and the returned {@link Iterable} will contain a single element: that
* path.
*
* <p>{@link DirectoryIteratorException} may be thrown when iterating {@link Iterable} instances
* created by this traverser if an {@link IOException} is thrown by a call to
* {@link #listFiles(Path)}.
*/
public static TreeTraverser<Path> directoryTreeTraverser() {
return DirectoryTreeTraverser.INSTANCE;
}
项目:googles-monorepo-demo
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:util
文件:FileTreeWalker.java
/**
* 直接使用Guava的TreeTraverser,获得更大的灵活度,比如加入各类filter,前序/后序的选择,一边遍历一边操作
*
* <pre>
* FileUtil.fileTreeTraverser().preOrderTraversal(root).iterator();
* </pre>
*/
public static TreeTraverser<File> fileTreeTraverser() {
return Files.fileTreeTraverser();
}
项目:codebuff
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:bts
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,and as such there is no
* way to ensure that a symbolic link to a directory is not followed when traversing the tree.
* In this case,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:guava-libraries
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:VectorAttackScanner
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:guava
文件:MoreFiles.java
/**
* Returns a {@link TreeTraverser} for traversing a directory tree. The returned traverser
* attempts to avoid following symbolic links to directories. However,no
* exception will be thrown and the returned {@link Iterable} will contain a single element: that
* path.
*
* <p>{@link DirectoryIteratorException} may be thrown when iterating {@link Iterable} instances
* created by this traverser if an {@link IOException} is thrown by a call to {@link
* #listFiles(Path)}.
*
* @deprecated The returned {@link TreeTraverser} type is deprecated. Use the replacement method
* {@link #fileTraverser()} instead with the same semantics as this method. This method is
* scheduled to be removed in April 2018.
*/
@Deprecated
public static TreeTraverser<Path> directoryTreeTraverser() {
return DirectoryTreeTraverser.INSTANCE;
}
项目:guava
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
* @deprecated The returned {@link TreeTraverser} type is deprecated. Use the replacement method
* {@link #fileTraverser()} instead with the same semantics as this method. This method is
* scheduled to be removed in April 2018.
*/
@Deprecated
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:cnGuava
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:org.openntf.domino
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:codebuff
文件:Files.java
/**
* Returns a {@link TreeTraverser} instance for {@link File} trees.
*
* <p><b>Warning:</b> {@code File} provides no support for symbolic links,iterables created by this traverser could contain files that are outside of the
* given directory or even be infinite if there is a symbolic link loop.
*
* @since 15.0
*/
public static TreeTraverser<File> fileTreeTraverser() {
return FILE_TREE_TRAVERSER;
}
项目:greyfish
文件:AbstractTree.java
protected abstract TreeTraverser<T> getTreeTraverser();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。