List of usage examples for java.util.stream Collectors toCollection
public static <T, C extends Collection<T>> Collector<T, ?, C> toCollection(Supplier<C> collectionFactory)
From source file:org.jboss.errai.ui.rebind.TemplatedCodeDecorator.java
@SuppressWarnings("serial") private List<Statement> generateDataFieldMetas(final String dataFieldMetasVarName, final Decorable decorable) { final Map<String, DataField> annoMap = DataFieldCodeDecorator.aggregateDataFieldAnnotationMap(decorable, decorable.getType());//w w w . j a v a 2 s.c o m final List<Statement> stmts = new ArrayList<>(annoMap.size() + 1); stmts.add(declareFinalVariable(dataFieldMetasVarName, new TypeLiteral<Map<String, DataFieldMeta>>() { }, newObject(parameterizedAs(HashMap.class, typeParametersOf(String.class, DataFieldMeta.class)), annoMap.size()))); annoMap.entrySet().stream().map(entry -> { final String fieldName = entry.getKey(); final DataField dataField = entry.getValue(); Statement dataFieldMetaInstance; if (dataField.attributeRules().length == 0 && dataField.defaultStrategy().equals(ConflictStrategy.USE_TEMPLATE)) { dataFieldMetaInstance = newObject(DataFieldMeta.class); } else { dataFieldMetaInstance = newObject(DataFieldMeta.class, loadLiteral(dataField.attributeRules()), loadLiteral(dataField.defaultStrategy())); } return loadVariable(dataFieldMetasVarName).invoke("put", fieldName, dataFieldMetaInstance); }).collect(Collectors.toCollection(() -> stmts)); return stmts; }
From source file:de.bund.bfr.knime.gis.views.canvas.CanvasUtils.java
public static <T extends Element> Set<T> removeInvisibleElements(Set<T> elements, HighlightConditionList highlightConditions) { Set<T> removed = new LinkedHashSet<>(); highlightConditions.getConditions().stream().filter(c -> c.isInvisible()).forEach(c -> { Set<T> toRemove = c.getValues(elements).entrySet().stream().filter(e -> e.getValue() != 0.0) .map(e -> e.getKey()).collect(Collectors.toCollection(LinkedHashSet::new)); elements.removeAll(toRemove);//www . j av a2 s. c o m removed.addAll(toRemove); }); return removed; }
From source file:com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceTest.java
private Object[] filterTwoPolicySetsByByNonexistentPolicySet(final List<PolicySet> twoPolicySets) { return new Object[] { twoPolicySets, Stream.of(twoPolicySets.get(0).getName(), "noexistent-policy-set") .collect(Collectors.toCollection(LinkedHashSet::new)) }; }
From source file:de.bund.bfr.knime.gis.views.canvas.CanvasUtils.java
public static <V extends Node> Set<Edge<V>> removeNodelessEdges(Set<Edge<V>> edges, Set<V> nodes) { Set<Edge<V>> removed = edges.stream() .filter(e -> !nodes.contains(e.getFrom()) || !nodes.contains(e.getTo())) .collect(Collectors.toCollection(LinkedHashSet::new)); edges.removeAll(removed);/*from w w w . ja va 2s . c o m*/ return removed; }
From source file:com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceTest.java
private Object[] filterTwoPolicySetsByItself(final List<PolicySet> twoPolicySets) { return new Object[] { twoPolicySets, Stream.of(twoPolicySets.get(0).getName(), twoPolicySets.get(1).getName()) .collect(Collectors.toCollection(LinkedHashSet::new)), twoPolicySets.stream().collect(Collectors.toCollection(LinkedHashSet::new)) }; }
From source file:com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceTest.java
private Object[] filterTwoPolicySetsBySecondPolicySet(final List<PolicySet> twoPolicySets) { return new Object[] { twoPolicySets, Stream.of(twoPolicySets.get(1).getName()).collect(Collectors.toCollection(LinkedHashSet::new)), Stream.of(twoPolicySets.get(1)).collect(Collectors.toCollection(LinkedHashSet::new)) }; }
From source file:io.divolte.server.recordmapping.ConfigRecordMapper.java
private static List<FieldSetter> setterListFromConfig(final Schema schema, final Config config) { if (!config.hasPath("divolte.tracking.schema_mapping.fields")) { throw new SchemaMappingException("Schema mapping configuration has no field mappings."); }//from w w w. j av a2s . co m final Set<Entry<String, ConfigValue>> entrySet = config.getConfig("divolte.tracking.schema_mapping.fields") .root().entrySet(); return entrySet.stream().map((e) -> fieldSetterFromConfig(schema, e)) .collect(Collectors.toCollection(() -> new ArrayList<>(entrySet.size()))); }
From source file:com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceTest.java
private Object[] filterTwoPolicySetsByFirstSet(final List<PolicySet> twoPolicySets) { return new Object[] { twoPolicySets, Stream.of(twoPolicySets.get(0).getName()).collect(Collectors.toCollection(LinkedHashSet::new)), Stream.of(twoPolicySets.get(0)).collect(Collectors.toCollection(LinkedHashSet::new)) }; }
From source file:com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceTest.java
private Object[] filterOnePolicySetByItself(final List<PolicySet> onePolicySet) { return new Object[] { onePolicySet, Stream.of(onePolicySet.get(0).getName()).collect(Collectors.toCollection(LinkedHashSet::new)), onePolicySet.stream().collect(Collectors.toCollection(LinkedHashSet::new)) }; }
From source file:com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceTest.java
private Object[] filterOnePolicySetByEmptyEvaluationOrder(final List<PolicySet> onePolicySet) { return new Object[] { onePolicySet, PolicyEvaluationRequestV1.EMPTY_POLICY_EVALUATION_ORDER, onePolicySet.stream().collect(Collectors.toCollection(LinkedHashSet::new)) }; }