当前位置: 首页>>代码示例>>Java>>正文


Java TreeStream类代码示例

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


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

示例1: deleteEmptyFolders

import com.diffplug.common.tree.TreeStream; //导入依赖的package包/类
/** Deletes all empty folders (recursively). */
public static void deleteEmptyFolders(File d) throws IOException {
	retry(d, root -> {
		// define the directory hierarchy
		TreeDef<File> dirTree = file -> Arrays.stream(file.listFiles())
				.filter(File::isDirectory)
				.collect(Collectors.toList());
		// find all the empty directories
		List<File> emptyDirs = TreeStream.depthFirst(dirTree, root)
				.filter(dir -> dir.list().length == 0)
				.collect(Collectors.toList());
		for (File emptyDir : emptyDirs) {
			File toDelete = emptyDir;
			while (!toDelete.equals(root)) {
				Preconditions.checkArgument(toDelete.delete(), "Failed to delete %s", toDelete);
				toDelete = toDelete.getParentFile();
				if (toDelete.list().length > 0) {
					break;
				}
			}
		}
		return null;
	});
}
 
开发者ID:diffplug,项目名称:goomph,代码行数:25,代码来源:FileMisc.java

示例2: gitAttributes

import com.diffplug.common.tree.TreeStream; //导入依赖的package包/类
/** Returns all of the .gitattributes files which affect the given files. */
static List<File> gitAttributes(Iterable<File> files) {
	// build a radix tree out of all the parent folders in these files
	ConcurrentRadixTree<String> tree = new ConcurrentRadixTree<>(new DefaultCharSequenceNodeFactory());
	for (File file : files) {
		String parentPath = file.getParent() + File.separator;
		tree.putIfAbsent(parentPath, parentPath);
	}
	// traverse the edge nodes to find the outermost folders
	List<File> edgeFolders = TreeStream.depthFirst(Node::getOutgoingEdges, tree.getNode())
			.filter(node -> node.getOutgoingEdges().isEmpty() && node.getValue() != null)
			.map(node -> new File((String) node.getValue()))
			.collect(Collectors.toList());

	List<File> gitAttrFiles = new ArrayList<>();
	Set<File> visitedFolders = new HashSet<>();
	for (File edgeFolder : edgeFolders) {
		gitAttrAddWithParents(edgeFolder, visitedFolders, gitAttrFiles);
	}
	return gitAttrFiles;
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:22,代码来源:GitAttributesLineEndings.java

示例3: getContents

import com.diffplug.common.tree.TreeStream; //导入依赖的package包/类
protected String getContents(Predicate<String> subpathsToInclude) throws IOException {
	TreeDef<File> treeDef = TreeDef.forFile(Errors.rethrow());
	List<File> files = TreeStream.depthFirst(treeDef, rootFolder())
			.filter(File::isFile)
			.collect(Collectors.toList());

	ListIterator<File> iterator = files.listIterator(files.size());
	int rootLength = rootFolder().getAbsolutePath().length() + 1;
	return StringPrinter.buildString(printer -> Errors.rethrow().run(() -> {
		while (iterator.hasPrevious()) {
			File file = iterator.previous();
			String subPath = file.getAbsolutePath().substring(rootLength);
			if (subpathsToInclude.test(subPath)) {
				printer.println("### " + subPath + " ###");
				printer.println(read(subPath));
			}
		}
	}));
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:20,代码来源:GradleIntegrationTest.java

示例4: TableAndTree

import com.diffplug.common.tree.TreeStream; //导入依赖的package包/类
TableAndTree(Composite cmp, int style) {
	Layouts.setFill(cmp);

	ColumnViewerFormat<TreeNode<String>> format = ColumnViewerFormat.builder();
	format.setStyle(style | SWT.FULL_SELECTION);
	format.addColumn().setText("First").setLabelProviderText(getPlace(0));
	format.addColumn().setText("Last").setLabelProviderText(getPlace(1));

	// create a table
	table = format.buildTable(new Composite(cmp, SWT.BORDER));
	table.setContentProvider(new ArrayContentProvider());
	List<TreeNode<String>> listInput = TreeStream.depthFirst(TreeNode.treeDef(), testData)
			.filter(node -> node.getContent().contains(" "))
			.collect(Collectors.toList());
	table.setInput(listInput);

	// and a tree
	tree = format.buildTree(new Composite(cmp, SWT.BORDER));
	ViewerMisc.setTreeContentProvider(tree, TreeNode.treeDef());
	tree.setInput(testData);
}
 
开发者ID:diffplug,项目名称:durian-swt,代码行数:22,代码来源:ViewerMiscTest.java

示例5: exec

import com.diffplug.common.tree.TreeStream; //导入依赖的package包/类
/**
 * @param project	the project on which we'll call {@link Project#javaexec(Action)}.
 * @param input		the JavaExecable which we'll take as input and call run() on.
 * @param settings	any extra settings you'd like to set on the JavaExec (e.g. heap)
 * @return the JavaExecable after it has had run() called.
 */
public static <T extends JavaExecable> T exec(Project project, T input, Action<JavaExecSpec> settings) throws Throwable {
	// copy the classpath from the project's buildscript (and its parents)
	List<FileCollection> classpaths = TreeStream.toParent(ProjectPlugin.treeDef(), project)
			.map(p -> p.getBuildscript().getConfigurations().getByName(BUILDSCRIPT_CLASSPATH))
			.collect(Collectors.toList());
	// add the gradleApi, workaround from https://discuss.gradle.org/t/gradle-doesnt-add-the-same-dependencies-to-classpath-when-applying-plugins/9759/6?u=ned_twigg
	classpaths.add(project.getConfigurations().detachedConfiguration(project.getDependencies().gradleApi()));
	// add stuff from the local classloader too, to fix testkit's classpath
	classpaths.add(JavaExecableImp.fromLocalClassloader());
	// run it
	FileCollection classpath = new UnionFileCollection(classpaths);
	return JavaExecableImp.execInternal(input, classpath, settings, execSpec -> JavaExecWinFriendly.javaExec(project, execSpec));
}
 
开发者ID:diffplug,项目名称:goomph,代码行数:20,代码来源:JavaExecable.java

示例6: setEnabledDeep

import com.diffplug.common.tree.TreeStream; //导入依赖的package包/类
/** Sets the enabled status of every child, grandchild, etc. of the given composite.  Skips plain-jane Composites. */
public static void setEnabledDeep(Composite root, boolean enabled) {
	TreeStream.depthFirst(treeDefControl(), root)
			// skip plain-jane Composites
			.filter(ctl -> ctl.getClass().equals(Composite.class))
			// set the enabled flag
			.forEach(ctl -> ctl.setEnabled(enabled));
}
 
开发者ID:diffplug,项目名称:durian-swt,代码行数:9,代码来源:SwtMisc.java


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