Java Code Examples for java.util.stream.Stream.Builder#build()

The following examples show how to use java.util.stream.Stream.Builder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemUtils.java    From Fibry with MIT License 5 votes vote down vote up
/**
 * @param parent starting directory
 * @return a list with all the files
 */
public static Stream<File> getAllFilesStream(File parent) {
    List<File> files = getAllFiles(parent);

    Builder<File> builder = Stream.<File>builder();

    for (File file : files)
        builder.accept(file);

    return builder.build();
}
 
Example 2
Source File: TypeInfo.java    From smallrye-graphql with Apache License 2.0 5 votes vote down vote up
/** <code>this</code> and all enclosing types, i.e. the types this type is nested in. */
public Stream<TypeInfo> enclosingTypes() {
    // requires JDK 9: return Stream.iterate(this, TypeInfo::hasEnclosingType, TypeInfo::enclosingType);
    Builder<TypeInfo> builder = Stream.builder();
    for (Class<?> enclosing = getRawType(); enclosing != null; enclosing = enclosing.getEnclosingClass())
        builder.accept(TypeInfo.of(enclosing));
    return builder.build();
}
 
Example 3
Source File: CalibrateColorCheckerBase.java    From testing-video with GNU General Public License v3.0 5 votes vote down vote up
public Stream<Args> colorchecker(int window) {
    Builder<Args> builder = Stream.builder();

    for (int i = 0; i < CLASSIC_24.size(); i++) {
        var column = CLASSIC_24.get(i);

        for (int j = 0; j < column.size(); j++) {
            builder.add(colorchecker(window, i, j));
        }
    }

    return builder.build();
}
 
Example 4
Source File: DB.java    From fastquery with Apache License 2.0 5 votes vote down vote up
private static Stream<String> parserSQLFile(String name) {
	Builder<String> builder = Stream.builder();

	try (FileReader reader = new FileReader(name); BufferedReader br = new BufferedReader(reader)) {
		StringBuilder buff = new StringBuilder();
		String str;
		while ((str = br.readLine()) != null) {
			str = str.trim();
			if (!"".startsWith(str) && !str.startsWith("#") && !str.startsWith("--")) {
				buff.append(str);
				buff.append(' ');
				int index = buff.indexOf(";");
				if(index != -1) {
					builder.add(buff.substring(0,index).trim());
					buff.delete(0, index+1);
				}
			}
		}
		
		String lastStr = buff.toString().trim();
		if(!"".equals(lastStr)) {
			builder.add(lastStr);
		}
		
	} catch (Exception e) {
		throw new RepositoryException(e);
	}

	return builder.build();
}
 
Example 5
Source File: JavaScriptBootstrapUI.java    From flow with Apache License 2.0 5 votes vote down vote up
@Override
public Stream<Component> getChildren() {
    // server-side routing
    if (wrapperElement == null) {
        return super.getChildren();
    }

    // client-side routing,
    // since virtual child is used, it is necessary to change the original
    // UI element to the wrapperElement
    Builder<Component> childComponents = Stream.builder();
    wrapperElement.getChildren().forEach(childElement -> ComponentUtil
            .findComponents(childElement, childComponents::add));
    return childComponents.build();
}