List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:org.jnode.jersey.JNContainer.java
@Override public void incomingRequest(BasicHttpRequest req, NHttpResponse res) { try {// w w w . j a va 2 s.c o m log.trace("Incoming request"); final URI baseUri = getBaseUri(req); final URI requestUri = getRequestUri(req, baseUri); ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri, req.getRequestLine().getMethod(), null, new MapPropertiesDelegate()); requestContext.setEntityStream(new ByteArrayInputStream("".getBytes())); Arrays.stream(req.getAllHeaders()).forEach((Header he) -> { requestContext.headers(he.getName(), he.getValue()); }); requestContext.setWriter(new Writer(res)); requestContext.setRequestScopedInitializer(new RequestScopedInitializer() { @Override public void initialize(ServiceLocator locator) { // locator.<Ref<BasicHttpRequest>>getService(RequestTYPE).set(req); // locator.<Ref<NHttpResponse>>getService(ResponseTYPE).set(res); } }); requestContext.setSecurityContext(new BaseSecurityContext()); handler.handle(requestContext); } catch (Throwable t) { log.error("Unhandle exception ", t); res.end(); } }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesRedisService.java
@Override public Jedis connectToPrimaryService(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings) { ServiceSettings settings = runtimeSettings.getServiceSettings(this); List<String> command = Arrays.stream(connectCommand(details, runtimeSettings).split(" ")) .collect(Collectors.toList()); JobRequest request = new JobRequest().setTokenizedCommand(command); String jobId = getJobExecutor().startJob(request); // Wait for the proxy to spin up. DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(5)); JobStatus status = getJobExecutor().updateJob(jobId); // This should be a long-running job. if (status.getState() == JobStatus.State.COMPLETED) { throw new HalException(Problem.Severity.FATAL, "Unable to establish a proxy against Redis:\n" + status.getStdOut() + "\n" + status.getStdErr()); }// w w w . j a v a 2 s . c o m return new Jedis("localhost", settings.getPort()); }
From source file:com.cybernostics.jsp2thymeleaf.api.util.AlternateFormatStrings.java
public AlternateFormatStrings(String... formatStrings) { candidateFormats = Arrays.stream(formatStrings).map(item -> parse(item)).collect(Collectors.toList()); }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings.java
void mergePreferThis(ServiceSettings other) { Arrays.stream(getClass().getDeclaredMethods()).forEach(m -> { m.setAccessible(true);/*from w w w.ja v a 2 s . c om*/ if (!m.getName().startsWith("get")) { return; } String setterName = "s" + m.getName().substring(1); Method s; try { s = getClass().getDeclaredMethod(setterName, m.getReturnType()); } catch (NoSuchMethodException e) { return; } try { Object oThis = m.invoke(this); Object oOther = m.invoke(other); if (oThis == null) { s.invoke(this, oOther); } } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Unable to merge service settings: " + e.getMessage(), e); } finally { m.setAccessible(false); } }); }
From source file:com.blackducksoftware.integration.hub.detect.configuration.DetectConfiguration.java
private void init() { Arrays.stream(DetectProperty.values()).forEach(currentProperty -> { final DetectProperty override = fromDeprecatedToOverride(currentProperty); final DetectProperty deprecated = fromOverrideToDeprecated(currentProperty); if (override == null && deprecated == null) { handleStandardProperty(currentProperty); } else if (override != null) { handleDeprecatedProperty(currentProperty, override);// a deprecated property has an override } else if (deprecated != null) { handleOverrideProperty(currentProperty, deprecated);// an override property has a deprecated property }//w ww. j a v a2s. c o m }); //TODO: Find a better way to do this - or - hopefully remove this if the scan cli gets better. String bdScanPaths = detectPropertySource.getProperty("BD_HUB_SCAN_PATH"); if (StringUtils.isNotBlank(bdScanPaths)) { logger.warn("The environment variable BD_HUB_SCAN_PATH was set but you should use --" + DetectProperty.DETECT_BLACKDUCK_SIGNATURE_SCANNER_PATHS.getPropertyKey() + " instead."); List<String> values = new ArrayList<>(); values.addAll(Arrays.asList(getStringArrayProperty( DetectProperty.DETECT_BLACKDUCK_SIGNATURE_SCANNER_PATHS, PropertyAuthority.None))); values.addAll(Arrays.asList(bdScanPaths.split(","))); setDetectProperty(DetectProperty.DETECT_BLACKDUCK_SIGNATURE_SCANNER_PATHS, values.stream().collect(Collectors.joining(","))); } }
From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java
public HandRank getHand(Player p, Board b) throws InvalidHandException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { Card[] holeCards = p.getHoleCards(); Card[] board = b.getBoard();//w ww. j av a 2 s . c o m Card[] c = ArrayUtils.addAll(board, holeCards); Arrays.stream(c).forEach((card) -> { haveCard(card); }); return getHand(); }
From source file:org.osiam.Osiam.java
private static String extractCommand(String[] arguments) { return Arrays.stream(arguments).map(String::trim).filter(argument -> !argument.startsWith("-")) .filter(argument -> !argument.startsWith("--")).findFirst().orElse("server"); }
From source file:org.openlmis.fulfillment.service.request.RequestHelper.java
/** * Split the given {@link RequestParameters} into smaller chunks. *//*w w w.j a v a 2 s. c o m*/ public static URI[] splitRequest(String url, RequestParameters queryParams, int maxUrlLength) { RequestParameters safeQueryParams = RequestParameters.init().setAll(queryParams); URI uri = createUri(url, safeQueryParams); if (uri.toString().length() > maxUrlLength) { Pair<RequestParameters, RequestParameters> split = safeQueryParams.split(); if (null != split.getLeft() && null != split.getRight()) { URI[] left = splitRequest(url, split.getLeft(), maxUrlLength); URI[] right = splitRequest(url, split.getRight(), maxUrlLength); return Stream.concat(Arrays.stream(left), Arrays.stream(right)).distinct().toArray(URI[]::new); } } return new URI[] { uri }; }
From source file:com.walmart.gatling.endpoint.v1.FileUploadController.java
@RequestMapping(method = RequestMethod.GET, value = "/upload") public String provideUploadInfo(Model model) throws IOException { File rootFolder = new File(tempFileDir); if (!rootFolder.exists()) { rootFolder.mkdir();// www. j av a 2 s .c o m } rootFolder = new File(tempFileDir); model.addAttribute("files", Arrays.stream(rootFolder.listFiles()).sorted(Comparator.comparingLong(f -> -1 * f.lastModified())) .map(f -> f.getName()).collect(Collectors.toList())); return "uploadForm"; }
From source file:fi.hsl.parkandride.itest.HubsAndFacilitiesReportITest.java
private void checkHubsAndFacilities_operatorsAre(Workbook workbook, Operator... operators) { final Sheet facilities = workbook.getSheetAt(1); final List<String> expectedColumns = newArrayList("Operaattori"); expectedColumns.addAll(Arrays.stream(operators).map(o -> o.name.fi).collect(toList())); assertThat(getDataFromColumn(facilities, 3)).containsExactlyElementsOf(expectedColumns); }