List of usage examples for java.util Spliterators spliteratorUnknownSize
public static Spliterator.OfDouble spliteratorUnknownSize(PrimitiveIterator.OfDouble iterator, int characteristics)
From source file:com.ikanow.aleph2.search_service.elasticsearch.utils.ElasticsearchIndexUtils.java
/** Utility function to handle fields * TODO (ALEPH-14): need to be able to specify different options for different fields via columnar settings * @param mutable_mapping//from www .j a va 2 s. com * @param fielddata_info * @param mapper */ protected static void handleMappingFields(final ObjectNode mutable_mapping, final Optional<Tuple3<JsonNode, JsonNode, Boolean>> fielddata_info, final ObjectMapper mapper, final String index_type) { Optional.ofNullable(mutable_mapping.get("fields")).filter(j -> !j.isNull() && j.isObject()).ifPresent(j -> { StreamSupport.stream(Spliterators.spliteratorUnknownSize(j.fields(), Spliterator.ORDERED), false) .forEach(Lambdas.wrap_consumer_u(kv -> { final ObjectNode mutable_o = (ObjectNode) kv.getValue(); setMapping(mutable_o, fielddata_info, mapper, index_type); })); }); }
From source file:org.apache.wicket.MarkupContainer.java
/** * Returns a sequential {@code Stream} with the all children of this markup container as its * source. This stream does traverse the component tree. * //from w w w .ja v a 2 s . c om * @return a sequential {@code Stream} over the all children of this markup container * @since 8.0 */ @SuppressWarnings("unchecked") public Stream<Component> streamChildren() { class ChildrenIterator<C> implements Iterator<C> { private Iterator<C> currentIterator; private Deque<Iterator<C>> iteratorStack = new ArrayDeque<>(); private ChildrenIterator(Iterator<C> iterator) { currentIterator = iterator; } @Override public boolean hasNext() { if (!currentIterator.hasNext() && !iteratorStack.isEmpty()) { currentIterator = iteratorStack.pop(); } return currentIterator.hasNext(); } @Override public C next() { C child = currentIterator.next(); if (child instanceof Iterable) { iteratorStack.push(currentIterator); currentIterator = ((Iterable<C>) child).iterator(); } return child; } } return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new ChildrenIterator<>(iterator()), 0), false); }
From source file:org.kie.workbench.common.dmn.backend.DMNMarshallerTest.java
@Test public void test_function_java_WB_model() throws IOException { final DMNMarshaller m = getDMNMarshaller(); @SuppressWarnings("unchecked") final Graph<?, Node<?, ?>> g = m.unmarshall(null, this.getClass().getResourceAsStream("/DROOLS-2372.dmn")); final Stream<Node<?, ?>> stream = StreamSupport .stream(Spliterators.spliteratorUnknownSize(g.nodes().iterator(), Spliterator.ORDERED), false); final Optional<Decision> wbDecision = stream.filter(n -> n.getContent() instanceof ViewImpl) .map(n -> (ViewImpl) n.getContent()).filter(n -> n.getDefinition() instanceof Decision) .map(n -> (Decision) n.getDefinition()).findFirst(); wbDecision.ifPresent(d -> {// w ww .ja v a 2s. c om assertTrue(d.getExpression() instanceof FunctionDefinition); final FunctionDefinition wbFunction = (FunctionDefinition) d.getExpression(); //This is what the WB expects assertEquals(FunctionDefinition.Kind.JAVA, wbFunction.getKind()); }); final DMNRuntime runtime = roundTripUnmarshalMarshalThenUnmarshalDMN( this.getClass().getResourceAsStream("/DROOLS-2372.dmn")); final DMNModel dmnModel = runtime.getModels().get(0); final BusinessKnowledgeModelNode bkmNode = dmnModel.getBusinessKnowledgeModels().iterator().next(); final org.kie.dmn.model.api.FunctionDefinition dmnFunction = bkmNode.getBusinessKnowledModel() .getEncapsulatedLogic(); assertEquals(FunctionKind.JAVA, dmnFunction.getKind()); }
From source file:com.joyent.manta.client.MantaClient.java
/** * Gets all of the Manta jobs' IDs as a real-time {@link Stream} from * the Manta API. <strong>Make sure to close this stream when you are done with * otherwise the HTTP socket will remain open.</strong> * * @return a stream with all of the job IDs (actually all that Manta will give us) *///from w w w . j av a 2 s . c o m public Stream<UUID> getAllJobIds() { final String path = String.format("%s/jobs", config.getMantaHomeDirectory()); final MantaDirectoryListingIterator itr = new MantaDirectoryListingIterator(path, httpHelper, MAX_RESULTS); danglingStreams.add(itr); Stream<Map<String, Object>> backingStream = StreamSupport .stream(Spliterators.spliteratorUnknownSize(itr, Spliterator.ORDERED | Spliterator.NONNULL), false); return backingStream.map(item -> { final String id = Objects.toString(item.get("name")); return UUID.fromString(id); }); }
From source file:org.kie.workbench.common.dmn.backend.DMNMarshallerTest.java
private static Node<View, ?> nodeOfDefinition(final Iterator<Node<View, ?>> nodesIterator, final Class aClass) { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(nodesIterator, Spliterator.NONNULL), false) .filter(node -> aClass.isInstance(node.getContent().getDefinition())).findFirst().get(); }