java.util.stream.BaseStream Java Examples
The following examples show how to use
java.util.stream.BaseStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbandonedStream.java From huntbugs with Apache License 2.0 | 6 votes |
@AstVisitor(nodes=AstNodes.EXPRESSIONS, minVersion=8) public void visit(Expression expr, MethodContext mc) { if(expr.getCode() == AstCode.InvokeInterface) { MethodReference mr = (MethodReference) expr.getOperand(); if(mr.getReturnType().getPackageName().equals("java.util.stream") && Types.isBaseStream(mr.getReturnType())) { // intermediate stream operation if(mc.isAnnotated() && !Inf.BACKLINK.findTransitiveUsages(expr, true).findAny().isPresent()) { // .parallel()/.sequential()/.onClose()/.unordered() excluded as may return itself if(Types.is(mr.getReturnType(), BaseStream.class)) { mc.report("StreamMethodMayNotReturnItself", 0, expr); } else { mc.report("AbandonedStream", 0, expr); } } } } }
Example #2
Source File: TestUtil.java From hol-streams with Apache License 2.0 | 6 votes |
/** * Tests a stream of any kind against a reference stream of the same type. * * @param instance from which to extract the stream * @param reference stream * @param creator to apply when creating a new stream * @param collector to apply to the two streams -> List * @param <I> Type of the instance from which streams are obtained * @param <T> Elements in the stream * @param <S> Stream type, E.g. Stream<String> or IntStream */ static <I, T, S extends BaseStream> void tester( final I instance, final S reference, final Function<I, S> creator, final Function<S, List<T>> collector ) { // Create the stream to test final S stream = creator.apply(instance); // Make sure that the streams have the same parallel property assertEquals(reference.isParallel(), stream.isParallel()); // Make sure that streams are not reused assertNotSame(creator.apply(instance) , stream); // Make sure that the streams have the same content final List<T> expected = collector.apply(reference); final List<T> actual = collector.apply(stream); assertEquals(expected, actual); printContent(actual); }
Example #3
Source File: ConcatEngine.java From jenetics with Apache License 2.0 | 6 votes |
@Override public EvolutionStream<G, C> stream(final Supplier<EvolutionStart<G, C>> start) { final AtomicReference<EvolutionStart<G, C>> other = new AtomicReference<>(null); return new EvolutionStreamImpl<>( new ConcatSpliterator<>( _engines.stream() .map(engine -> engine .stream(() -> start(start, other)) .peek(result -> other.set(result.toEvolutionStart()))) .map(BaseStream::spliterator) .collect(Collectors.toList()) ), false ); }
Example #4
Source File: BuildableListProperty.java From FreeBuilder with Apache License 2.0 | 5 votes |
private void addStreamBuilderAddAll(SourceBuilder code) { code.addLine(""); addJavadocForAddingMultipleBuilders(code); code.addLine("public %s %s(%s<? extends %s, ?> elementBuilders) {", datatype.getBuilder(), addAllBuildersOfMethod(property), BaseStream.class, element.builderType()) .addLine(" return %s(elementBuilders.spliterator());", addAllBuildersOfMethod(property)) .addLine("}"); }
Example #5
Source File: StreamContext.java From streamex with Apache License 2.0 | 5 votes |
StreamContext combine(BaseStream<?, ?> other) { if (other == null) return this; StreamContext otherStrategy = of(other); StreamContext result = this; if (other.isParallel() && !parallel) result = parallel(); if (otherStrategy.closeHandler != null) result = result.onClose(otherStrategy.closeHandler); return result; }
Example #6
Source File: BuildableListProperty.java From FreeBuilder with Apache License 2.0 | 5 votes |
private void addStreamValueInstanceAddAll(SourceBuilder code) { code.addLine(""); addJavadocForAddingMultipleValues(code); code.addLine("public %s %s(%s<? extends %s, ?> elements) {", datatype.getBuilder(), addAllMethod(property), BaseStream.class, element.type()) .addLine(" return %s(elements.spliterator());", addAllMethod(property)) .addLine("}"); }
Example #7
Source File: MultisetProperty.java From FreeBuilder with Apache License 2.0 | 5 votes |
private void addStreamAddAll(SourceBuilder code) { addJavadocForAddAll(code); code.addLine("public %s %s(%s<? extends %s, ?> elements) {", datatype.getBuilder(), addAllMethod(property), BaseStream.class, elementType) .addLine(" return %s(elements.spliterator());", addAllMethod(property)) .addLine("}"); }
Example #8
Source File: SortedMergeIterator.java From stream-utils with Apache License 2.0 | 5 votes |
/** * Creates a new SortedMerge Iterator. * * @param streams a list of ordered streams to merge. * @param comparator the comparator that all those streams are sorted by. */ public SortedMergeIterator(List<Stream<TYPE>> streams, Comparator<TYPE> comparator) { // take the full list of streams this.iterators = streams.stream() // turn them into iterators .map(BaseStream::iterator) // wrap them in peeking iterators .map(PeekingIterator::new) // collect that into a list .collect(Collectors.toList()); this.comparator = comparator; }
Example #9
Source File: SortedSetProperty.java From FreeBuilder with Apache License 2.0 | 5 votes |
private void addStreamAddAll(SourceBuilder code) { addJavadocForAddAll(code); code.addLine("public %s %s(%s<? extends %s, ?> elements) {", datatype.getBuilder(), addAllMethod(property), BaseStream.class, elementType) .addLine(" return %s(elements.spliterator());", addAllMethod(property)) .addLine("}"); }
Example #10
Source File: ListProperty.java From FreeBuilder with Apache License 2.0 | 5 votes |
private void addStreamAddAll(SourceBuilder code) { addJavadocForAddAll(code); code.addLine("public %s %s(%s<? extends %s, ?> elements) {", datatype.getBuilder(), addAllMethod(property), BaseStream.class, elementType) .addLine(" return %s(elements.spliterator());", addAllMethod(property)) .addLine("}"); }
Example #11
Source File: SetProperty.java From FreeBuilder with Apache License 2.0 | 5 votes |
private void addStreamAddAll(SourceBuilder code) { addJavadocForAddAll(code); code.addLine("public %s %s(%s<? extends %s, ?> elements) {", datatype.getBuilder(), addAllMethod(property), BaseStream.class, elementType) .addLine(" return %s(elements.spliterator());", addAllMethod(property)) .addLine("}"); }
Example #12
Source File: ConcatEngine.java From jenetics with Apache License 2.0 | 5 votes |
private Collection<Spliterator<EvolutionResult<G, C>>> spliterators( final EvolutionInit<G> init, final AtomicReference<EvolutionStart<G, C>> other ) { final Collection<Spliterator<EvolutionResult<G, C>>> result; if (_engines.isEmpty()) { result = Collections.emptyList(); } else if (_engines.size() == 1) { result = List.of( _engines.get(0) .stream(init) .peek(er -> other.set(er.toEvolutionStart())) .spliterator() ); } else { final List<Spliterator<EvolutionResult<G, C>>> concat = new ArrayList<>(); concat.add( _engines.get(0) .stream(init) .peek(er -> other.set(er.toEvolutionStart())) .spliterator() ); concat.addAll( _engines.subList(1, _engines.size()).stream() .map(engine -> engine .stream(other::get) .peek(er -> other.set(er.toEvolutionStart()))) .map(BaseStream::spliterator) .collect(Collectors.toList()) ); result = concat; } return result; }
Example #13
Source File: ConcatOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
void assertSized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertTrue(sp.estimateSize() < Long.MAX_VALUE); }
Example #14
Source File: ConcatOpTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #15
Source File: ConcatOpTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
void assertSized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertTrue(sp.estimateSize() < Long.MAX_VALUE); }
Example #16
Source File: ConcatOpTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #17
Source File: StreamContext.java From streamex with Apache License 2.0 | 4 votes |
static StreamContext of(BaseStream<?, ?> stream) { if (stream instanceof BaseStreamEx) return ((BaseStreamEx<?, ?, ?, ?>) stream).context; return new StreamContext(stream.isParallel()).onClose(stream::close); }
Example #18
Source File: ConcatOpTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
void assertSized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertTrue(sp.estimateSize() < Long.MAX_VALUE); }
Example #19
Source File: ConcatOpTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
void assertSized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertTrue(sp.estimateSize() < Long.MAX_VALUE); }
Example #20
Source File: ConcatOpTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #21
Source File: ConcatOpTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
void assertSized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertTrue(sp.estimateSize() < Long.MAX_VALUE); }
Example #22
Source File: ConcatOpTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #23
Source File: ConcatOpTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #24
Source File: ConcatOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #25
Source File: ConcatOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #26
Source File: ConcatOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
void assertSized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertTrue(sp.estimateSize() < Long.MAX_VALUE); }
Example #27
Source File: ConcatOpTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #28
Source File: ConcatOpTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
void assertSized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertTrue(sp.estimateSize() < Long.MAX_VALUE); }
Example #29
Source File: ConcatOpTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
void assertUnsized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertEquals(sp.estimateSize(), Long.MAX_VALUE); }
Example #30
Source File: ConcatOpTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
void assertSized(BaseStream<?, ?> s) { Spliterator<?> sp = s.spliterator(); assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED)); assertTrue(sp.estimateSize() < Long.MAX_VALUE); }