Example usage for java.util Arrays stream

List of usage examples for java.util Arrays stream

Introduction

In this page you can find the example usage for java.util Arrays stream.

Prototype

public static DoubleStream stream(double[] array) 

Source Link

Document

Returns a sequential DoubleStream with the specified array as its source.

Usage

From source file:org.ow2.proactive.connector.iaas.cloud.provider.vmware.VMWareProviderMacAddressHandler.java

/**
 * Retrieve a new VirtualDeviceConfigSpec with a customized VirtualEthernetCard's MAC address cloned from the
 * specified VM/*from  www . j  a v  a2 s .co  m*/
 *
 * @param macAddress    the MAC address to assign
 * @param vm            the original VM to clone (containing a VirtualEthernetCard)
 * @return  an optional VirtualDeviceConfigSpec[] (single object's array) with a customized VirtualEthernetCard
 */
Optional<VirtualDeviceConfigSpec[]> getVirtualDeviceConfigWithMacAddress(String macAddress, VirtualMachine vm) {

    return Arrays.stream(vm.getConfig().getHardware().getDevice())
            .filter(virtualDevice -> virtualDevice instanceof VirtualEthernetCard).findFirst()
            .map(virtualDevice -> getCustomizedVirtualEthernetCard(virtualDevice, macAddress))
            .map(this::getVirtualDeviceConfigSpec)
            .map(virtDevConfSpec -> new VirtualDeviceConfigSpec[] { virtDevConfSpec });

}

From source file:com.hubspot.jinjava.lib.filter.Filter.java

default Object filter(Object var, JinjavaInterpreter interpreter, Object[] args, Map<String, Object> kwargs) {
    // We append the named arguments at the end of the positional ones
    Object[] allArgs = ArrayUtils.addAll(args, kwargs.values().toArray());
    String[] stringArgs = Arrays.stream(allArgs).map(arg -> Objects.toString(arg, null)).toArray(String[]::new);

    return filter(var, interpreter, stringArgs);
}

From source file:se.uu.it.cs.recsys.dataloader.impl.CourseSelectionLoader.java

protected void parseCourseSelectionRecordFiles() throws IOException, DataSourceFileAccessException {
    if (!this.courseSelectionDir.exists()) {
        final String MSG = "No info about course selection source dir!";
        getLogger().error(MSG);//from w ww .  j  a  v a  2s.co  m
        throw new DataSourceFileAccessException(MSG);
    }

    Arrays.stream(this.courseSelectionDir.getFile().listFiles()).forEach(file -> {
        try {
            parseFile(file);
        } catch (IOException ex) {
            getLogger().error("Failed processing file: {}", file.getName(), ex);
        }
    });

}

From source file:io.github.jeddict.orm.generator.compiler.constraints.PatternSnippet.java

public PatternSnippet(Pattern pattern) {
    super(pattern);
    if (isNotBlank(constraint.getFlags())) {
        flags = Arrays.stream(constraint.getFlags().split(COMMA)).map(flag -> Flag.fromValue(flag.trim()))
                .filter(flag -> nonNull(flag)).collect(toList());
    }/*w  ww.j  a v  a  2s.c  o m*/
}

From source file:de.micromata.genome.logging.web.FormUrlEncodedBodyWriter.java

private Stream<String> getParametersUrlEncoded(final String key, String[] parameters) {
    return Arrays.stream(parameters)
            .filter(p -> StringUtils.isBlank(key) == false && StringUtils.isBlank(p) == false)
            .map(p -> urlEncode(key) + "=" + urlEncode(p));
}

From source file:com.thoughtworks.go.config.CaseInsensitiveString.java

public static List<String> toStringList(CaseInsensitiveString... strings) {
    return toStringList(Arrays.stream(strings));
}

From source file:com.ponysdk.impl.spring.server.SpringApplicationManager.java

@Override
protected EntryPoint initializeEntryPoint() {
    try (ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            configurations)) {// w w  w  .ja  v a 2  s  .  co  m
        final String[] serverActiveProfiles = configuration.getApplicationContext().getEnvironment()
                .getActiveProfiles();
        Arrays.stream(serverActiveProfiles)
                .forEach(profile -> applicationContext.getEnvironment().addActiveProfile(profile));

        final EntryPoint entryPoint = applicationContext.getBean(EntryPoint.class);

        final Map<String, InitializingActivity> initializingPages = applicationContext
                .getBeansOfType(InitializingActivity.class);
        if (initializingPages != null && !initializingPages.isEmpty()) {
            initializingPages.values().forEach(InitializingActivity::afterContextInitialized);
        }

        return entryPoint;
    }
}

From source file:me.tfeng.toolbox.spring.BeanNameRegistry.java

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
    ApplicationContext applicationContext = event.getApplicationContext();
    Arrays.stream(applicationContext.getBeanDefinitionNames()).forEach(name -> {
        try {//from  w  w w  .  j  a v  a2  s  .c o  m
            beanMap.put(new ShadowKey(applicationContext.getBean(name)), name);
        } catch (NoSuchBeanDefinitionException e) {
            // Ignore.
        }
    });
}

From source file:org.trustedanalytics.resourceserver.data.InputStreamProvider.java

/**
 * Gets an InputStream for a path on HDFS.
 *
 * If given path is a directory, it will read files inside that dir and create
 * a SequenceInputStream from them, which emulates reading from directory just like from
 * a regular file. Notice that this method is not meant to read huge datasets
 * (as well as the whole project).// www  .ja  va 2s .  c om
 * @param path
 * @return
 * @throws IOException
 */
public InputStream getInputStream(Path path) throws IOException {
    Objects.requireNonNull(path);
    if (fs.isFile(path)) {
        return fs.open(path);
    } else if (fs.isDirectory(path)) {
        FileStatus[] files = fs.listStatus(path);
        List<InputStream> paths = Arrays.stream(files).map(f -> {
            try {
                return fs.open(f.getPath());
            } catch (IOException e) {
                LOGGER.log(Level.SEVERE, "Cannot read file " + f.getPath().toString(), e);
                return null;
            }
        }).filter(f -> f != null).collect(Collectors.toList());
        return new SequenceInputStream(Collections.enumeration(paths));
    } else {
        throw new IllegalArgumentException("Given path " + path.toString() + " is neither file nor directory");
    }
}

From source file:co.runrightfast.vertx.core.RunRightFastVerticleId.java

public String verticleJmxDomain(final String... subDomains) {
    final StringBuilder sb = new StringBuilder(80).append(RUNRIGHTFAST_JMX_DOMAIN)
            .append(String.format(".vertx/%s-%s-%s", group, name, version));
    if (ArrayUtils.isNotEmpty(subDomains)) {
        Arrays.stream(subDomains).forEach(subDomain -> sb.append('/').append(subDomain));
    }//from ww  w  .j av a 2  s.co m
    return sb.toString();
}