• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TreeTraverser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.common.collect.TreeTraverser的典型用法代码示例。如果您正苦于以下问题:Java TreeTraverser类的具体用法?Java TreeTraverser怎么用?Java TreeTraverser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TreeTraverser类属于com.google.common.collect包,在下文中一共展示了TreeTraverser类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
@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";
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:27,代码来源:MenuManagerController.java


示例2: testWeCanGetTheSpecificationHierarchy

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
@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());
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:37,代码来源:FileSystemRepositoryTest.java


示例3: treeTraverserOf

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
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);
    }
  };
}
 
开发者ID:futuresimple,项目名称:dex-method-counts,代码行数:9,代码来源:DexMethodCounts.java


示例4: preOrderTraversal

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
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);
}
 
开发者ID:JetBrains,项目名称:mapper,代码行数:9,代码来源:Composites.java


示例5: preOrder

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
public static Stream<Node> preOrder(Node node)
{
    return TreeTraverser.using((Node n) -> unmodifiableIterable(n.getChildren()))
            .preOrderTraversal(requireNonNull(node, "node is null"))
            .stream();
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:7,代码来源:AstUtils.java


示例6: GuavaTraversal

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
GuavaTraversal(final TreeTraverser<E> traverser)
{
    this.traverser = traverser;
}
 
开发者ID:JavaChat,项目名称:streems,代码行数:5,代码来源:GuavaTraversal.java


示例7: breadthFirstTraversalFromRoot

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
public Iterable<FactoryBase<?,V>> breadthFirstTraversalFromRoot(){
    factory.prepareIterationRunFromRoot();
    final TreeTraverser<FactoryBase<?,V>> factoryTraverser = new FactoryTreeTraverser<>();
    return factoryTraverser.breadthFirstTraversal(factory);
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:6,代码来源:FactoryBase.java


示例8: postOrderTraversalFromRoot

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
public Iterable<FactoryBase<?,V>> postOrderTraversalFromRoot(){
    factory.prepareIterationRunFromRoot();
    final TreeTraverser<FactoryBase<?,V>> factoryTraverser = new FactoryTreeTraverser<>();
    return factoryTraverser.postOrderTraversal(factory);
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:6,代码来源:FactoryBase.java


示例9: getTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
public TreeTraverser<TreeNode<K,V>> getTraverser() {
    return new Traverser();
}
 
开发者ID:rhlabs,项目名称:louie,代码行数:4,代码来源:Tree.java


示例10: traverse

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:JavaChat,项目名称:streems,代码行数:17,代码来源:GuavaStreems.java


示例11: directoryTreeTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:19,代码来源:MoreFiles.java


示例12: fileTreeTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:14,代码来源:Files.java


示例13: fileTreeTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
/**
 * 直接使用Guava的TreeTraverser,获得更大的灵活度, 比如加入各类filter,前序/后序的选择,一边遍历一边操作
 * 
 * <pre>
 * FileUtil.fileTreeTraverser().preOrderTraversal(root).iterator();
 * </pre>
 */
public static TreeTraverser<File> fileTreeTraverser() {
	return Files.fileTreeTraverser();
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:11,代码来源:FileTreeWalker.java


示例14: fileTreeTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:14,代码来源:Files.java


示例15: directoryTreeTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
/**
 * 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)}.
 *
 * @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;
}
 
开发者ID:google,项目名称:guava,代码行数:24,代码来源:MoreFiles.java


示例16: fileTreeTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
/**
 * 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
 * @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;
}
 
开发者ID:google,项目名称:guava,代码行数:18,代码来源:Files.java


示例17: fileTreeTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:16,代码来源:Files.java


示例18: getTreeTraverser

import com.google.common.collect.TreeTraverser; //导入依赖的package包/类
protected abstract TreeTraverser<T> getTreeTraverser(); 
开发者ID:asoem,项目名称:greyfish,代码行数:2,代码来源:AbstractTree.java



注:本文中的com.google.common.collect.TreeTraverser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MultipartUploadListing类代码示例发布时间:2022-05-21
下一篇:
Java RegionServerTracker类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap