List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:org.bremersee.common.spring.autoconfigure.LdaptiveInMemoryDirectoryServerProperties.java
public String[] getLdifLocationsAsArray() { if (StringUtils.hasText(ldifLocations)) { String[] values = ldifLocations.split(Pattern.quote(",")); return Arrays.stream(values).map(String::trim).toArray(size -> new String[size]); }//w ww . j av a 2s . co m return new String[0]; }
From source file:com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder.java
private List<File> findFilesRecursive(final File sourceDirectory, final int currentDepth, final int maxDepth, StringBuilder maxDepthHitMsgPattern, final Boolean recurseIntoDirectoryMatch, final String... filenamePatterns) { final List<File> files = new ArrayList<>(); if (currentDepth >= maxDepth) { if (StringUtils.isNotBlank(maxDepthHitMsgPattern)) { logger.warn(String.format(maxDepthHitMsgPattern.toString(), sourceDirectory.getAbsolutePath())); // Ensure msg only shown once maxDepthHitMsgPattern.setLength(0); }/*from w ww. j a v a2 s .c om*/ } else if (sourceDirectory.isDirectory()) { File[] children = sourceDirectory.listFiles(); if (children != null && children.length > 0 && null != filenamePatterns && filenamePatterns.length >= 1) { for (final File file : children) { final boolean fileMatchesPatterns = Arrays.stream(filenamePatterns) .anyMatch(pattern -> FilenameUtils.wildcardMatchOnSystem(file.getName(), pattern)); if (fileMatchesPatterns) { files.add(file); } if (file.isDirectory() && (!fileMatchesPatterns || recurseIntoDirectoryMatch)) { // only go into the directory if it is not a match OR it is a match and the flag is set to go into matching directories files.addAll(findFilesRecursive(file, currentDepth + 1, maxDepth, maxDepthHitMsgPattern, recurseIntoDirectoryMatch, filenamePatterns)); } } } else if (children == null) { logger.warn("Directory contents could not be accessed: " + sourceDirectory.getAbsolutePath()); } } return files; }
From source file:sx.blah.discord.handle.impl.obj.Channel.java
/** * Makes a request to Discord for message history. * * @param before The ID of the message to get message history before. * @param limit The maximum number of messages to request. * @return The received messages./* ww w.j av a2 s . c o m*/ */ private IMessage[] getHistory(long before, int limit) { PermissionUtils.requirePermissions(this, client.getOurUser(), Permissions.READ_MESSAGES); String query = "?before=" + Long.toUnsignedString(before) + "&limit=" + limit; MessageObject[] messages = client.REQUESTS.GET.makeRequest( DiscordEndpoints.CHANNELS + getStringID() + "/messages" + query, MessageObject[].class); return Arrays.stream(messages).map(m -> DiscordUtils.getMessageFromJSON(this, m)).toArray(IMessage[]::new); }
From source file:com.twosigma.beakerx.kernel.magic.command.MavenJarResolver.java
private List<String> mavenBuildClasspath() { String jarPathsAsString = null; try {// w w w . ja v a 2s. c o m File fileToClasspath = new File(pathToMavenRepo, MAVEN_BUILT_CLASSPATH_FILE_NAME); InputStream fileInputStream = new FileInputStream(fileToClasspath); jarPathsAsString = IOUtils.toString(fileInputStream, StandardCharsets.UTF_8); } catch (IOException e) { throw new RuntimeException(e); } Stream<String> stream = Arrays.stream(jarPathsAsString.split(File.pathSeparator)); return stream.map(x -> Paths.get(x).getFileName().toString()).collect(Collectors.toList()); }
From source file:ddf.security.SubjectUtils.java
public static String filterDN(X500Principal principal, Predicate<RDN> predicate) { RDN[] rdns = Arrays.stream(new X500Name(principal.getName()).getRDNs()).filter(predicate) .toArray(RDN[]::new); return new X500Name(rdns).toString(); }
From source file:com.github.aptd.simulation.elements.IBaseElement.java
@Override public final Stream<ILiteral> literal(final IElement<?>... p_object) { return this.literal(Arrays.stream(p_object)); }
From source file:org.ligoj.app.plugin.prov.aws.ProvAwsTerraformService.java
private void writeRegion(final Context context) throws IOException { final List<ProvQuoteInstance> instances = new ArrayList<>(); context.getQuote().getInstances().stream() .filter(i -> getLocation(i).getName().equals(context.getLocation())).forEach(instances::add); final Map<InstanceMode, List<ProvQuoteInstance>> modes = new EnumMap<>(InstanceMode.class); Arrays.stream(InstanceMode.values()).forEach(m -> modes.put(m, new ArrayList<>())); instances.stream().forEach(i -> modes.get(toMode(i)).add(i)); context.setModes(modes);/* w ww .j av a2 s.c om*/ writeRegionStatics(context); writeRegionOs(context, instances); writeRegionDashboard(context); writeRegionInstances(context); }
From source file:com.evolveum.midpoint.model.intest.manual.CsvBackingStore.java
private String formatCsvLine(String[] data) { return Arrays.stream(data).map(s -> "\"" + s + "\"").collect(Collectors.joining(",")) + "\n"; }
From source file:io.bitgrillr.gocddockerexecplugin.docker.DockerUtils.java
/** * Return a String representation of the given command and arguments, e.g. "'echo 'hello' 'world'". * * @param command Command.//from w w w . j a va 2 s . co m * @param arguments Arguments. * @return Printable String. */ public static String getCommandString(String command, String... arguments) { return (new StringBuilder()).append("'").append(command) .append(Arrays.stream(arguments) .reduce(new StringBuilder(), (accumulator, value) -> accumulator.append(" '").append(value).append("'"), (partial1, partial2) -> partial1.append(partial2.toString())) .toString()) .append("'").toString(); }
From source file:com.offbynull.coroutines.instrumenter.asm.SearchUtils.java
/** * Find instructions in a certain class that are of a certain set of opcodes. * @param insnList instruction list to search through * @param opcodes opcodes to search for//w w w .j a v a 2s . c o m * @return list of instructions that contain the opcodes being searched for * @throws NullPointerException if any argument is {@code null} * @throws IllegalArgumentException if {@code opcodes} is empty */ public static List<AbstractInsnNode> searchForOpcodes(InsnList insnList, int... opcodes) { Validate.notNull(insnList); Validate.notNull(opcodes); Validate.isTrue(opcodes.length > 0); List<AbstractInsnNode> ret = new LinkedList<>(); Set<Integer> opcodeSet = new HashSet<>(); Arrays.stream(opcodes).forEach((x) -> opcodeSet.add(x)); Iterator<AbstractInsnNode> it = insnList.iterator(); while (it.hasNext()) { AbstractInsnNode insnNode = it.next(); if (opcodeSet.contains(insnNode.getOpcode())) { ret.add(insnNode); } } return ret; }