List of usage examples for java.util Collection stream
default Stream<E> stream()
From source file:ch.sdi.report.SdiReporter.java
/** * @param aResult/*from w w w . jav a 2 s . com*/ * @param aFiltered */ private void appendFiltered(StringBuilder aSb, Collection<ReportMsg> aFiltered) { appendTitle(aSb, "Filtered while collecting the raw data", "-"); aFiltered.stream() .filter(msg -> (msg.getKey().equals("Skpped Persons (no mail address)")) && msg.getValue() instanceof Collection) .map(msg -> Collection.class.cast(msg.getValue())).forEach(list -> appendDatasetList(aSb, list)); }
From source file:io.syndesis.rest.v1.state.ClientSideState.java
public <T> Set<T> restoreFrom(final Collection<Cookie> cookies, final Class<T> type) { return cookies.stream().flatMap(c -> { try {/* www .j ava2 s. c o m*/ return Stream.of(restoreWithTimestamp(c, type)); } catch (final IllegalArgumentException e) { LOG.warn("Unable to restore client side state from cookie: {}", c, e); return Stream.empty(); } }).sorted().map(t -> t.state).collect(Collectors.toCollection(LinkedHashSet::new)); }
From source file:org.obiba.mica.dataset.rest.entity.rql.RQLCriteriaOpalConverter.java
protected String join(String on, Collection<?> args) { String nOn = on;//from w ww . jav a2 s . co m boolean toQuote = getNature().equals(VariableNature.CATEGORICAL); List<String> nArgs = args.stream().map(arg -> { String nArg = arg instanceof DateTime ? normalizeDate((DateTime) arg) : arg.toString(); if (toQuote) return quote(nArg); else return normalizeString(nArg); }).collect(Collectors.toList()); return Joiner.on(nOn).join(nArgs); }
From source file:org.createnet.raptor.models.objects.ServiceObject.java
/** * Add a list of actions to the object/*from ww w .ja va 2 s . c o m*/ * * @param values list of actions * @return */ public ServiceObject addActions(Collection<Action> values) { values.stream().forEach((action) -> { action.setServiceObject(this); this.actions.put(action.name, action); }); return this; }
From source file:com.github.yongchristophertang.engine.web.request.HttpRequestBuilders.java
/** * Add a multi value request parameter to {@link HttpRequestBuilders}. * * @param name the parameter name//from ww w. j av a 2s. c o m * @param values multi values of the parameter */ public HttpRequestBuilders param(String name, Collection<String> values) { Objects.requireNonNull(name, "parameter name must not be null"); parameters.addAll(values.stream().map(v -> new BasicNameValuePair(name, v)).collect(Collectors.toList())); return this; }
From source file:ch.sdi.report.SdiReporter.java
/** * @param aResult/*from w ww. j a v a 2 s . co m*/ * @param aSkippedNoEmail */ private void appendSkippedNoEmail(StringBuilder aSb, Collection<ReportMsg> aSkippedNoEmail) { appendTitle(aSb, "Skipped because there is no email address", "-"); aSkippedNoEmail.stream() .filter(msg -> (msg.getKey().equals("Skpped Persons (no mail address)")) && msg.getValue() instanceof Collection) .map(msg -> Collection.class.cast(msg.getValue())).forEach(list -> appendPersonList(aSb, list)); }
From source file:com.github.yongchristophertang.engine.web.request.HttpRequestBuilders.java
public HttpRequestBuilders body(String param, Collection<String> values) { notNull(param, "Parameter must not be null"); bodyParameters/*from www. j av a 2s . c o m*/ .addAll(values.stream().map(v -> new BasicNameValuePair(param, v)).collect(Collectors.toList())); return this; }
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.PhotoInspectorImpl.java
private void updateRatingPicker(Collection<Photo> photos) { ratingPicker.setRating(null);/*ww w.ja v a2s . c o m*/ List<Rating> ratings = photos.stream().map(photo -> photo.getData().getRating()).distinct() .collect(Collectors.toList()); if (ratings.size() == 1) { ratingPicker.setRating(ratings.get(0)); } }
From source file:com.netflix.spinnaker.orca.clouddriver.tasks.providers.aws.AmazonImageTagger.java
@Override public ImageTagger.OperationContext getOperationContext(Stage stage) { StageData stageData = (StageData) stage.mapTo(StageData.class); Collection<MatchedImage> matchedImages = findImages(stageData.imageNames, stage); if (stageData.regions == null || stageData.regions.isEmpty()) { stageData.regions = matchedImages.stream().flatMap(matchedImage -> matchedImage.amis.keySet().stream()) .collect(Collectors.toSet()); }// w w w. j a v a2 s .co m stageData.imageNames = matchedImages.stream().map(matchedImage -> matchedImage.imageName) .collect(Collectors.toList()); // Built-in tags are not updatable Map<String, String> tags = stageData.tags.entrySet().stream() .filter(entry -> !BUILT_IN_TAGS.contains(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); List<Image> targetImages = new ArrayList<>(); Map<String, Object> originalTags = new HashMap<>(); List<Map<String, Map>> operations = new ArrayList<>(); for (MatchedImage matchedImage : matchedImages) { Image targetImage = new Image(matchedImage.imageName, defaultBakeAccount, stageData.regions, tags); targetImages.add(targetImage); log.info(format("Tagging '%s' with '%s' (executionId: %s)", targetImage.imageName, targetImage.tags, stage.getExecution().getId())); // Update the tags on the image in the `defaultBakeAccount` operations.add(ImmutableMap.<String, Map>builder().put(OPERATION, ImmutableMap.builder().put("amiName", targetImage.imageName).put("tags", targetImage.tags) .put("regions", targetImage.regions).put("credentials", targetImage.account).build()) .build()); // Re-share the image in all other accounts (will result in tags being updated) matchedImage.accounts.stream().filter(account -> !account.equalsIgnoreCase(defaultBakeAccount)) .forEach(account -> { stageData.regions .forEach(region -> operations.add(ImmutableMap.<String, Map>builder() .put(ALLOW_LAUNCH_OPERATION, ImmutableMap.builder().put("account", account) .put("credentials", defaultBakeAccount).put("region", region) .put("amiName", targetImage.imageName).build()) .build())); }); originalTags.put(matchedImage.imageName, matchedImage.tagsByImageId); } Map<String, Object> extraOutput = objectMapper.convertValue(stageData, Map.class); extraOutput.put("targets", targetImages); extraOutput.put("originalTags", originalTags); return new ImageTagger.OperationContext(operations, extraOutput); }
From source file:com.yahoo.elide.jsonapi.models.JsonApiDocument.java
@Override public boolean equals(Object obj) { if (!(obj instanceof JsonApiDocument)) { return false; }// w ww . j av a 2 s. c o m JsonApiDocument other = (JsonApiDocument) obj; Collection<Resource> resources = data.get(); if ((resources == null || other.getData().get() == null) && resources != other.getData().get()) { return false; } else if (resources != null) { if (resources.size() != other.getData().get().size() || !resources.stream().allMatch(other.getData().get()::contains)) { return false; } } // TODO: Verify links and meta? if (other.getIncluded() == null) { return included.isEmpty(); } return included.stream().allMatch(other.getIncluded()::contains); }