List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:ee.ria.xroad.common.certificateprofile.impl.AbstractCertificateProfileInfo.java
private DnFieldDescription getDescription(DnFieldValue value) { return Arrays.stream(fields).filter(f -> f.getId().equals(value.getId())).findFirst() .orElseThrow(() -> new RuntimeException("Unknown field: " + value.getId())); }
From source file:com.compomics.colims.core.io.headers.ProteinGroupHeaders.java
/** * Parse a TSV file and create a map for each line that maps the keys found on the first line to the values found to * the values found on lines two and further until the end of the file. * * @param tsvFile tab separated values file * @throws IOException// ww w. j a va 2s . c o m */ private void readFileHeaders(final File tsvFile) throws IOException { headersInProteinGroupFile = new ArrayList<>(); fileReader = new FileReader(tsvFile); lineReader = new LineReader(fileReader); String firstLine = lineReader.readLine(); if (firstLine == null || firstLine.isEmpty()) { throw new IOException("Input file " + tsvFile.getPath() + " is empty."); } else { String[] headers = firstLine.toLowerCase(Locale.US).split("" + DELIMITER); Arrays.stream(headers).forEach(e -> headersInProteinGroupFile.add(e)); } }
From source file:org.hsweb.web.mybatis.MybatisProperties.java
public Resource[] resolveMapperLocations() { Map<String, Resource> resources = new HashMap<>(); Set<String> locations; if (this.getMapperLocations() == null) locations = new HashSet<>(); else/*from w ww . j a va 2 s .c o m*/ locations = Arrays.stream(getMapperLocations()).collect(Collectors.toSet()); locations.add(defaultMapperLocation); for (String mapperLocation : locations) { Resource[] mappers; try { mappers = new PathMatchingResourcePatternResolver().getResources(mapperLocation); for (Resource mapper : mappers) { resources.put(mapper.getURL().toString(), mapper); } } catch (IOException e) { } } //??? if (mapperLocationExcludes != null && mapperLocationExcludes.length > 0) { for (String mapperLocationExclude : mapperLocationExcludes) { try { Resource[] excludesMappers = new PathMatchingResourcePatternResolver() .getResources(mapperLocationExclude); for (Resource excludesMapper : excludesMappers) { resources.remove(excludesMapper.getURL().toString()); } } catch (IOException e) { } } } Resource[] mapperLocations = new Resource[resources.size()]; mapperLocations = resources.values().toArray(mapperLocations); return mapperLocations; }
From source file:io.syndesis.jsondb.impl.JsonRecordSupport.java
public static String convertToDBPath(String base) { String value = Arrays.stream(base.split("/")).filter(x -> !x.isEmpty()).map( x -> INTEGER_PATTERN.matcher(validateKey(x)).matches() ? toArrayIndexPath(Integer.parseInt(x)) : x) .collect(Collectors.joining("/")); return Strings.suffix(Strings.prefix(value, "/"), "/"); }
From source file:com.adobe.acs.commons.data.Spreadsheet.java
/** * Simple constructor used for unit testing purposes * * @param convertHeaderNames If true, header names are converted * @param headerArray List of strings for header columns *//*from ww w . jav a 2s.c o m*/ public Spreadsheet(boolean convertHeaderNames, String... headerArray) { this.enableHeaderNameConversion = convertHeaderNames; headerTypes = Arrays.stream(headerArray) .collect(Collectors.toMap(this::convertHeaderName, this::detectTypeFromName)); headerRow = Arrays.asList(headerArray); requiredColumns = Collections.EMPTY_LIST; dataRows = new ArrayList<>(); delimiters = new HashMap<>(); }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
/** * Gets the models. This method is used if ModelPath is passed as parameter. * /* w ww. j av a2 s. c om*/ * * @return the models */ public static String[] getModels(String modelDirectory) { File dir = new File(modelDirectory); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> models = new ArrayList<>(); String[] modelNames = getModelNames(); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }
From source file:org.ow2.proactive.workflow_catalog.rest.service.BucketService.java
@PostConstruct public void init() throws Exception { boolean isTestProfileEnabled = Arrays.stream(environment.getActiveProfiles()).anyMatch("test"::equals); // We define the initial start by no existing buckets in the Catalog // On initial start, we load the Catalog with predefined Workflows if (!isTestProfileEnabled && bucketRepository.count() == 0) { populateCatalog(defaultBucketNames, DEFAULT_WORKFLOWS_FOLDER); }/*w ww . j av a 2 s . c o m*/ }
From source file:io.pivotal.strepsirrhini.chaoslemur.RandomFateEngine.java
private boolean isBlacklisted(Member member) { return Arrays.stream(this.blacklist) .anyMatch(s -> member.getDeployment().equalsIgnoreCase(s) || member.getJob().equalsIgnoreCase(s)); }
From source file:com.github.ljtfreitas.restify.http.spring.contract.metadata.reflection.SpringWebRequestMappingMetadata.java
private Optional<String> produces() { return Optional.ofNullable(mapping).map(m -> m.produces()).filter(c -> c.length >= 1) .map(h -> Arrays.stream(h).filter(c -> c != null && !c.isEmpty()).collect(Collectors.joining(", "))) .map(c -> HttpHeaders.ACCEPT + "=" + c); }
From source file:ijfx.ui.datadisplay.table.SaveCSV.java
@Override public void run() { if (displayService.getActiveDisplay() instanceof TableDisplay) { try {/*ww w . j a va2 s . c o m*/ csvFileFormat = csvFileFormat.withDelimiter(delimiter.charAt(0)); tableDisplay = (TableDisplay) displayService.getActiveDisplay(); fileWriter = new FileWriter(file.getAbsolutePath()); csvFilePrinter = new CSVPrinter(fileWriter, csvFileFormat); String[] headers = header.split(delimiter); if (headers.length != tableDisplay.get(0).size() && !header.equals("")) { String message = "The number of header doesn't match with the number of columns"; uIService.showDialog(message, DialogPrompt.MessageType.ERROR_MESSAGE); return; } else { csvFilePrinter.printRecord(Arrays.stream(headers).collect(Collectors.toList())); } for (int i = 0; i < tableDisplay.get(0).get(0).size(); i++) { List line = new ArrayList(); for (int j = 0; j < tableDisplay.get(0).size(); j++) { line.add(tableDisplay.get(0).get(j, i).toString()); } csvFilePrinter.printRecord(line); } fileWriter.flush(); fileWriter.close(); csvFilePrinter.close(); } catch (IOException ex) { Logger.getLogger(SaveCSV.class.getName()).log(Level.SEVERE, null, ex); } } }