List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:com.talanlabs.sonar.plugins.gitlab.AbstractCommentBuilder.java
protected Map<String, Object> createContext() { Map<String, Object> root = new HashMap<>(); // Config/*from ww w . j a v a2s . c om*/ root.put("projectId", gitLabPluginConfiguration.projectId()); root.put("commitSHA", gitLabPluginConfiguration.commitSHA()); root.put("refName", gitLabPluginConfiguration.refName()); root.put("url", gitLabPluginConfiguration.url()); root.put("maxGlobalIssues", gitLabPluginConfiguration.maxGlobalIssues()); root.put("maxBlockerIssuesGate", gitLabPluginConfiguration.maxBlockerIssuesGate()); root.put("maxCriticalIssuesGate", gitLabPluginConfiguration.maxCriticalIssuesGate()); root.put("maxMajorIssuesGate", gitLabPluginConfiguration.maxMajorIssuesGate()); root.put("maxMinorIssuesGate", gitLabPluginConfiguration.maxMinorIssuesGate()); root.put("maxInfoIssuesGate", gitLabPluginConfiguration.maxInfoIssuesGate()); root.put("disableIssuesInline", !gitLabPluginConfiguration.tryReportIssuesInline()); root.put("disableGlobalComment", !gitLabPluginConfiguration.disableGlobalComment()); root.put("onlyIssueFromCommitFile", gitLabPluginConfiguration.onlyIssueFromCommitFile()); root.put("commentNoIssue", gitLabPluginConfiguration.commentNoIssue()); // Report root.put("revision", revision); Arrays.stream(Severity.values()).forEach(severity -> root.put(severity.name(), severity)); root.put("issueCount", new IssueCountTemplateMethodModelEx(reportIssues)); root.put("issues", new IssuesTemplateMethodModelEx(reportIssues)); root.put("print", new PrintTemplateMethodModelEx(markDownUtils)); root.put("emojiSeverity", new EmojiSeverityTemplateMethodModelEx(markDownUtils)); root.put("imageSeverity", new ImageSeverityTemplateMethodModelEx(markDownUtils)); root.put("ruleLink", new RuleLinkTemplateMethodModelEx(markDownUtils)); return root; }
From source file:com.ikanow.aleph2.analytics.spark.assets.BeFileInputFormat_Pure.java
@Override public List<InputSplit> getSplits(JobContext context) throws IOException { logger.debug("BeFileInputFormat.getSplits"); super.setMaxSplitSize(MAX_SPLIT_SIZE); try {/*from w w w . ja va2 s . c o m*/ final List<InputSplit> splits = Lambdas.get(Lambdas.wrap_u(() -> { final List<InputSplit> tmp = super.getSplits(context); String debug_max_str = context.getConfiguration().get(HadoopBatchEnrichmentUtils.BE_DEBUG_MAX_SIZE); if (null != debug_max_str) { final int requested_records = Integer.parseInt(debug_max_str); // dump 5* the request number of splits into one mega split // to strike a balance between limiting the data and making sure for // tests that enough records are generated final CombineFileSplit combined = new CombineFileSplit( tmp.stream().map(split -> (CombineFileSplit) split) .flatMap(split -> Arrays.stream(split.getPaths())).limit(5L * requested_records) .<Path>toArray(size -> new Path[size]), ArrayUtils.toPrimitive( tmp.stream().map(split -> (CombineFileSplit) split) .flatMap(split -> Arrays.stream(split.getStartOffsets()).boxed()) .limit(5L * requested_records).<Long>toArray(size -> new Long[size]), 0L), ArrayUtils.toPrimitive( tmp.stream().map(split -> (CombineFileSplit) split) .flatMap(split -> Arrays.stream(split.getLengths()).boxed()) .limit(5L * requested_records).<Long>toArray(size -> new Long[size]), 0L), tmp.stream().map(split -> (CombineFileSplit) split) .flatMap(Lambdas.wrap_u(split -> Arrays.stream(split.getLocations()))) .limit(5L * requested_records).<String>toArray(size -> new String[size])); return Arrays.<InputSplit>asList(combined); } else return tmp; })); logger.debug("BeFileInputFormat.getSplits: " + ((splits != null) ? splits.size() : "null")); return splits; } catch (Throwable t) { logger.error(ErrorUtils.getLongForm("Error getting splits, error = {0}", t)); return Collections.emptyList(); } }
From source file:jease.cms.domain.Content.java
/** * Returns all properties for given name. *///w w w . j a v a 2 s . c o m public Property[] getProperties(final String name) { return Arrays.stream(properties).filter(property -> property != null && name.equals(property.getName())) .toArray(Property[]::new); }
From source file:com.haulmont.cuba.gui.ControllerDependencyInjector.java
protected static List<Method> getAnnotatedListenerMethodsNotCached(Class<?> clazz) { Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz); List<Method> eventListenerMethods = Arrays.stream(methods) .filter(m -> m.getAnnotation(EventListener.class) != null).collect(Collectors.toList()); if (eventListenerMethods.isEmpty()) { return Collections.emptyList(); }/* w w w.j ava 2 s .c o m*/ return ImmutableList.copyOf(eventListenerMethods); }
From source file:com.yahoo.gondola.tsunami.Tsunami.java
public Tsunami() throws Exception { setup();/* w w w . ja v a2s . c o m*/ // Print status thread executorService.execute(() -> { while (true) { logger.info("writes: {}, reads: {}, errors: {}, waiting for index={} on {}", writes.get(), reads.get(), errors.get(), verifyWaitingForIndex, agents[verifyWaitingFor].hostId); logger.info(" " + Arrays.stream(agents).map(agent -> agent.hostId + ": up=" + agent.up) .collect(Collectors.joining(", "))); logger.info(" lastWrite: {}, lastRead: {}", lastWrittenIndex, lastReadIndex); sleep(10000); } }); executorService.execute(new Killer()); executorService.execute(new Verifier()); // Initialize writer threads. numWriter writers per gondola for (int a = 0; a < agents.length; a++) { AgentClient agent = agents[a]; for (int w = 0; w < numWriters; w++) { String writerId = String.format("%c%d", (char) ('A' + a), w); executorService.execute(new Writer(writerId, agent.hostname, agent.gondolaCc.getPort())); } } }
From source file:com.programmablefun.ide.editor.TextMateThemeLoader.java
private void convertEntry(Map<String, Object> entry) { String rawScopes = (String) entry.get("scope"); if (rawScopes == null) { Map<String, Object> settings = (Map<String, Object>) entry.get("settings"); this.stylesheet.selectionBackground = (String) settings.get("selection"); this.stylesheet.defaultBackground = (String) settings.get("background"); this.stylesheet.gutterForeground = (String) settings.get("gutterForeground"); this.stylesheet.gutterBackground = (String) settings.get("gutter"); // Not used: caret, invisibles, lineHighlight, gutterForeground, gutter stylesheet.styleOther = new Stylesheet.JsonStyle(); stylesheet.styleOther.attrs = Lists.newArrayList(); stylesheet.styleOther.fg = (String) settings.get("foreground"); } else {// www. j av a2 s . co m Set<String> scopes = Arrays.stream(rawScopes.split(",")).map(String::trim).collect(toSet()); Stylesheet.JsonStyle style = convertStyle((Map<String, Object>) entry.get("settings")); if (scopes.contains("comment")) { stylesheet.styleComment = style; } else if (scopes.contains("string")) { stylesheet.styleString = style; } else if (scopes.contains("keyword")) { stylesheet.styleKeyword = style; } else if (scopes.contains("variable")) { stylesheet.styleIdent = style; } else if (scopes.contains("constant.numeric")) { stylesheet.styleNumber = style; } else if (scopes.contains("support.function")) { stylesheet.styleWellKnownString = style; } } }
From source file:com.uber.hoodie.hadoop.realtime.AbstractRealtimeRecordReader.java
/** * Given a comma separated list of field names and positions at which they appear on Hive, return * a ordered list of field names, that can be passed onto storage. */// w ww . j a va2 s . c o m public static List<String> orderFields(String fieldNameCsv, String fieldOrderCsv, String partitioningFieldsCsv) { String[] fieldOrders = fieldOrderCsv.split(","); Set<String> partitioningFields = Arrays.stream(partitioningFieldsCsv.split(",")) .collect(Collectors.toSet()); List<String> fieldNames = Arrays.stream(fieldNameCsv.split(",")) .filter(fn -> !partitioningFields.contains(fn)).collect(Collectors.toList()); // Hive does not provide ids for partitioning fields, so check for lengths excluding that. if (fieldNames.size() != fieldOrders.length) { throw new HoodieException( String.format("Error ordering fields for storage read. #fieldNames: %d, #fieldPositions: %d", fieldNames.size(), fieldOrders.length)); } TreeMap<Integer, String> orderedFieldMap = new TreeMap<>(); for (int ox = 0; ox < fieldOrders.length; ox++) { orderedFieldMap.put(Integer.parseInt(fieldOrders[ox]), fieldNames.get(ox)); } return new ArrayList<>(orderedFieldMap.values()); }
From source file:alfio.model.Event.java
public Event(@Column("id") int id, @Column("type") EventType type, @Column("short_name") String shortName, @Column("display_name") String displayName, @Column("location") String location, @Column("latitude") String latitude, @Column("longitude") String longitude, @Column("start_ts") ZonedDateTime begin, @Column("end_ts") ZonedDateTime end, @Column("time_zone") String timeZone, @Column("website_url") String websiteUrl, @Column("external_url") String externalUrl, @Column("file_blob_id") String fileBlobId, @Column("website_t_c_url") String termsAndConditionsUrl, @Column("image_url") String imageUrl, @Column("currency") String currency, @Column("vat") BigDecimal vat, @Column("allowed_payment_proxies") String allowedPaymentProxies, @Column("private_key") String privateKey, @Column("org_id") int organizationId, @Column("locales") int locales, @Column("src_price_cts") int srcPriceInCents, @Column("vat_status") PriceContainer.VatStatus vatStatus, @Column("version") String version, @Column("status") Status status) { this.type = type; this.displayName = displayName; this.websiteUrl = websiteUrl; this.externalUrl = externalUrl; this.termsAndConditionsUrl = termsAndConditionsUrl; this.imageUrl = imageUrl; this.fileBlobId = fileBlobId; final ZoneId zoneId = TimeZone.getTimeZone(timeZone).toZoneId(); this.id = id; this.shortName = shortName; this.location = location; this.latitude = latitude; this.longitude = longitude; this.timeZone = zoneId; this.begin = begin.withZoneSameInstant(zoneId); this.end = end.withZoneSameInstant(zoneId); this.currency = currency; this.vatIncluded = vatStatus == PriceContainer.VatStatus.INCLUDED; this.vat = vat; this.privateKey = privateKey; this.organizationId = organizationId; this.locales = locales; this.allowedPaymentProxies = Arrays.stream(Optional.ofNullable(allowedPaymentProxies).orElse("").split(",")) .filter(StringUtils::isNotBlank).map(PaymentProxy::valueOf).collect(Collectors.toList()); this.vatStatus = vatStatus; this.srcPriceCts = srcPriceInCents; this.version = version; this.status = status; }
From source file:com.thinkbiganalytics.metadata.modeshape.security.role.JcrAbstractRoleMembership.java
@Override public void setMemebers(UsernamePrincipal... principals) { Set<UsernamePrincipal> newMembers = Arrays.stream(principals).collect(Collectors.toSet()); Set<UsernamePrincipal> oldMembers = streamUsers().collect(Collectors.toSet()); newMembers.stream().filter(u -> !oldMembers.contains(u)).forEach(this::addMember); oldMembers.stream().filter(u -> !newMembers.contains(u)).forEach(this::removeMember); }
From source file:org.leandreck.endpoints.processor.model.MethodNodeFactory.java
private static List<String> defineHttpMethods(final RequestMapping requestMapping) { final List<String> methods = new ArrayList<>(); if (requestMapping != null) { return Arrays.stream(requestMapping.method()) .map(requestMethod -> requestMethod.toString().toLowerCase(Locale.ENGLISH)).collect(toList()); }//from w ww .j av a2s . c o m return methods; }