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:com.dclab.preparation.ReadTest.java

public void dig(File folder) {
    File[] files = folder.listFiles();
    Logger.getAnonymousLogger().info("OPENING folder " + folder.getName());
    Map<Boolean, List<File>> isZip = Arrays.stream(files)
            .collect(Collectors.partitioningBy((f -> f.getName().endsWith("zip"))));
    Map<Boolean, List<File>> isFolder = isZip.get(false).stream()
            .collect(Collectors.partitioningBy(f -> f.isDirectory()));
    isFolder.get(false).stream().filter(y -> y.getName().endsWith("xml")).forEach(this::scanFile);
    isFolder.get(true).stream().forEach(this::dig);
    isZip.get(true).stream().forEach(z -> {
        try {//from w ww  . j a v a  2s . c o m
            ZipFile zipFile = new ZipFile(z);
            zipFile.stream().forEach(ze -> {
                try {
                    String s = handleZip(zipFile, ze);
                    if (s != null) {
                        printLine(s);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(ReadTest.class.getName()).log(Level.SEVERE, null, ex);
                }
            });
        } catch (IOException ex) {
            Logger.getLogger(ReadTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

}

From source file:com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardMavenLibrary.java

public static Optional<AppEngineStandardMavenLibrary> getLibraryByMavenDisplayName(final String name) {
    return Arrays.stream(AppEngineStandardMavenLibrary.values())
            .filter(library -> name.equals(library.toMavenDisplayVersion())).findAny();
}

From source file:me.yanaga.winter.data.jpa.spring.config.metadata.EnableRepositoriesMetadata.java

private static List<String> getBasePackageClassesAttributes(AnnotationMetadata annotationMetadata) {
    Class<?>[] basePackageClasses = (Class<?>[]) annotationMetadata.getAnnotationAttributes(ANNOTATION_NAME)
            .get(BASE_PACKAGE_CLASSES);//from  ww w  .ja  v a  2 s  . c  o  m
    return Arrays.stream(basePackageClasses).map(k -> k.getPackage().getName())
            .collect(collectingAndThen(toList(), ImmutableList::copyOf));
}

From source file:com.create.validation.RequiredOnPropertyValueValidator.java

private boolean isValueRequiringPropertyToBeSet(Object propertyValue) {
    final String stringPropertyValue = propertyValue.toString();
    return Arrays.stream(values).anyMatch(value -> value.equals(stringPropertyValue));
}

From source file:com.github.ukase.toolkit.fs.FileSource.java

@Autowired
public FileSource(UkaseSettings settings) throws IOException {
    templates = settings.getTemplates();
    resources = settings.getResources();

    if (resources != null) {
        resourcesListener = new FileUpdatesListener(resources);
        if (isSubDirectory(resources, templates)) {
            templatesListener = null;/*w  ww . java  2  s.  c  om*/
        } else {
            templatesListener = new FileUpdatesListener(templates);
        }

        File[] fontsFiles = resources.listFiles((dir, fileName) -> IS_FONT.test(fileName));
        fonts = Arrays.stream(fontsFiles).map(File::getAbsolutePath).collect(Collectors.toList());
    } else {
        resourcesListener = null;
        if (templates != null) {
            templatesListener = new FileUpdatesListener(templates);
        } else {
            templatesListener = null;
        }
        fonts = Collections.emptyList();
    }
}

From source file:example.UserInitializer.java

private static List<User> readUsers(Resource resource) throws Exception {

    Scanner scanner = new Scanner(resource.getInputStream());
    String line = scanner.nextLine();
    scanner.close();//w  ww  .  jav  a2 s  .  c  o  m

    FlatFileItemReader<User> reader = new FlatFileItemReader<User>();
    reader.setResource(resource);

    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setNames(line.split(","));
    tokenizer.setStrict(false);

    DefaultLineMapper<User> lineMapper = new DefaultLineMapper<User>();
    lineMapper.setFieldSetMapper(fields -> {

        User user = new User();

        user.setEmail(fields.readString("email"));
        user.setFirstname(capitalize(fields.readString("first")));
        user.setLastname(capitalize(fields.readString("last")));
        user.setNationality(fields.readString("nationality"));

        String city = Arrays.stream(fields.readString("city").split(" "))//
                .map(StringUtils::capitalize)//
                .collect(Collectors.joining(" "));
        String street = Arrays.stream(fields.readString("street").split(" "))//
                .map(StringUtils::capitalize)//
                .collect(Collectors.joining(" "));

        try {
            user.setAddress(new Address(city, street, fields.readString("zip")));
        } catch (IllegalArgumentException e) {
            user.setAddress(new Address(city, street, fields.readString("postcode")));
        }

        user.setPicture(new Picture(fields.readString("large"), fields.readString("medium"),
                fields.readString("thumbnail")));
        user.setUsername(fields.readString("username"));
        user.setPassword(fields.readString("password"));

        return user;
    });

    lineMapper.setLineTokenizer(tokenizer);

    reader.setLineMapper(lineMapper);
    reader.setRecordSeparatorPolicy(new DefaultRecordSeparatorPolicy());
    reader.setLinesToSkip(1);
    reader.open(new ExecutionContext());

    List<User> users = new ArrayList<>();
    User user = null;

    do {

        user = reader.read();

        if (user != null) {
            users.add(user);
        }

    } while (user != null);

    return users;
}

From source file:com.synopsys.integration.util.CleanupZipExpander.java

@Override
public void beforeExpansion(final File sourceArchiveFile, final File targetExpansionDirectory)
        throws IntegrationException {
    final File[] toDelete = targetExpansionDirectory.listFiles(file -> file.isDirectory() || alsoDeleteFiles);
    if (toDelete != null && toDelete.length > 0) {
        logger.warn(String.format(
                "There were items in %s that are being deleted. This may happen under normal conditions, but please do not place items in the expansion directory as this directory is assumed to be under the integration's control.",
                targetExpansionDirectory.getAbsolutePath()));
        Arrays.stream(toDelete).forEach(FileUtils::deleteQuietly);
    }//from ww  w .j  av  a 2  s. c o  m
}

From source file:com.nebhale.buildmonitor.web.AbstractControllerTest.java

final String toJson(String... pairs) {
    StringBuilder sb = new StringBuilder("{ ");

    Set<String> entries = Arrays.stream(pairs).map(pair -> {
        String[] parts = StringUtils.split(pair, ":");
        return String.format("\"%s\" : \"%s\"", parts[0], parts[1]);
    }).collect(Collectors.toSet());

    sb.append(StringUtils.collectionToDelimitedString(entries, ", "));

    return sb.append(" }").toString();
}

From source file:io.blobkeeper.file.service.FileListServiceImpl.java

@Override
public List<File> getFiles(int disk, @NotNull String pattern) {
    java.io.File filePath = getDiskPathByDisk(configuration, disk);
    checkArgument(filePath.exists(), "Base disk path must be exists");

    return Arrays.stream(filePath.list(new SuffixFileFilter(pattern)))
            .map(blobFileName -> getFile(filePath, blobFileName)).collect(toImmutableList());
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.table.EntityTable.java

public EntityTable(Class<E> entityClass) {
    if (entityClass == null) {
        throw new IllegalArgumentException("Entity type was not specified");
    }//from   w ww .  jav  a2s .c om

    this.entityClass = entityClass;
    List<String> headers = Arrays.stream(entityClass.getFields()).map(Field::getName)
            .collect(Collectors.toList());
    hasColumnHeaders(headers);
}