java.util.stream.Stream.Builder Java Examples
The following examples show how to use
java.util.stream.Stream.Builder.
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 |
/** * @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 |
/** <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 |
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: DruidDataSourceConfiguration.java From druid-spring-boot with Apache License 2.0 | 5 votes |
@Override public String[] selectImports(AnnotationMetadata metadata) { Map<String, Object> properties = resolver.getSubProperties(EMPTY); Builder<Class<?>> imposts = Stream.<Class<?>>builder().add(DruidDataSourceBeanPostProcessor.class); imposts.add(properties.isEmpty() ? SingleDataSourceRegistrar.class : DynamicDataSourceRegistrar.class); return imposts.build().map(Class::getName).toArray(String[]::new); }
Example #5
Source File: DB.java From fastquery with Apache License 2.0 | 5 votes |
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 #6
Source File: JavaScriptBootstrapUI.java From flow with Apache License 2.0 | 5 votes |
@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(); }
Example #7
Source File: HotSpotCompiledCodeBuilder.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static HotSpotCompiledCode createCompiledCode(ResolvedJavaMethod method, HotSpotCompilationRequest compRequest, CompilationResult compResult) { String name = compResult.getName(); byte[] targetCode = compResult.getTargetCode(); int targetCodeSize = compResult.getTargetCodeSize(); Site[] sites = getSortedSites(compResult); Assumption[] assumptions = compResult.getAssumptions(); ResolvedJavaMethod[] methods = compResult.getMethods(); List<CodeAnnotation> annotations = compResult.getAnnotations(); Comment[] comments = new Comment[annotations.size()]; if (!annotations.isEmpty()) { for (int i = 0; i < comments.length; i++) { CodeAnnotation annotation = annotations.get(i); String text; if (annotation instanceof CodeComment) { CodeComment codeComment = (CodeComment) annotation; text = codeComment.value; } else if (annotation instanceof JumpTable) { JumpTable jumpTable = (JumpTable) annotation; text = "JumpTable [" + jumpTable.low + " .. " + jumpTable.high + "]"; } else { text = annotation.toString(); } comments[i] = new Comment(annotation.position, text); } } DataSection data = compResult.getDataSection(); byte[] dataSection = new byte[data.getSectionSize()]; ByteBuffer buffer = ByteBuffer.wrap(dataSection).order(ByteOrder.nativeOrder()); Builder<DataPatch> patchBuilder = Stream.builder(); data.buildDataSection(buffer, vmConstant -> { patchBuilder.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant))); }); int dataSectionAlignment = data.getSectionAlignment(); DataPatch[] dataSectionPatches = patchBuilder.build().toArray(len -> new DataPatch[len]); int totalFrameSize = compResult.getTotalFrameSize(); StackSlot customStackArea = compResult.getCustomStackArea(); boolean isImmutablePIC = compResult.isImmutablePIC(); if (method instanceof HotSpotResolvedJavaMethod) { HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; int entryBCI = compResult.getEntryBCI(); boolean hasUnsafeAccess = compResult.hasUnsafeAccess(); int id; long jvmciEnv; if (compRequest != null) { id = compRequest.getId(); jvmciEnv = compRequest.getJvmciEnv(); } else { id = hsMethod.allocateCompileId(entryBCI); jvmciEnv = 0L; } return new HotSpotCompiledNmethod(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, customStackArea, hsMethod, entryBCI, id, jvmciEnv, hasUnsafeAccess); } else { return new HotSpotCompiledCode(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, customStackArea); } }
Example #8
Source File: AttendsSearchController.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
@RequestMapping(value = "/sendEmail", method = RequestMethod.POST) public RedirectView sendEmail(Model model, HttpServletRequest request, HttpSession session, @RequestParam("filteredAttendsJson") String filteredAttendsJson, @RequestParam("filtersJson") String filtersJson, final RedirectAttributes redirectAttributes) { JsonObject filters = new JsonParser().parse(filtersJson).getAsJsonObject(); StringBuilder attendTypeValues = parseFilters(filters, "attendsStates", "type"); StringBuilder degreeNameValues = parseFilters(filters, "curricularPlans", "name"); StringBuilder shiftsValues = parseFilters(filters, "shifts", "name"); StringBuilder studentStatuteTypesValues = parseFilters(filters, "studentStatuteTypes", "name"); JsonObject noStatuteObject = filters.get("noStudentStatuteTypes").getAsJsonObject(); if (noStatuteObject.get("value").getAsBoolean()) { studentStatuteTypesValues.append(noStatuteObject.get("shortName")); } String label = String.format("%s : %s \n%s : %s \n%s : %s \n%s : %s", BundleUtil.getString(Bundle.APPLICATION, "label.selectStudents"), attendTypeValues.toString(), BundleUtil.getString(Bundle.APPLICATION, "label.attends.courses"), degreeNameValues.toString(), BundleUtil.getString(Bundle.APPLICATION, "label.selectShift"), shiftsValues.toString(), BundleUtil.getString(Bundle.APPLICATION, "label.studentStatutes"), studentStatuteTypesValues.toString()); Builder<Attends> builder = Stream.builder(); for (JsonElement elem : new JsonParser().parse(filteredAttendsJson).getAsJsonArray()) { JsonObject object = elem.getAsJsonObject(); builder.accept(FenixFramework.getDomainObject(object.get("id").getAsString())); } Group users = Group.users(builder.build().map(a -> a.getRegistration().getPerson().getUser()).filter(Objects::nonNull) .sorted(User.COMPARATOR_BY_NAME)); NamedGroup named = new NamedGroup(new LocalizedString(I18N.getLocale(),label) ,users); MessageBean bean = new MessageBean(); bean.setLockedSender(executionCourse.getSender()); bean.addAdHocRecipient(named); bean.selectRecipient(named); redirectAttributes.addFlashAttribute("messageBean",bean); return new RedirectView("/messaging/message", true); }