当前位置: 首页>>代码示例>>Java>>正文


Java BaseStream类代码示例

本文整理汇总了Java中java.util.stream.BaseStream的典型用法代码示例。如果您正苦于以下问题:Java BaseStream类的具体用法?Java BaseStream怎么用?Java BaseStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BaseStream类属于java.util.stream包,在下文中一共展示了BaseStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import java.util.stream.BaseStream; //导入依赖的package包/类
@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);
                }
            }
        }
    }
}
 
开发者ID:amaembo,项目名称:huntbugs,代码行数:19,代码来源:AbandonedStream.java

示例2: getCollectionStream

import java.util.stream.BaseStream; //导入依赖的package包/类
@Override public Stream<T> getCollectionStream(Repository repository) {
    Stream<T> stream = Stream.empty();
    List<Stream<T>> streams = new ArrayList<>();
    Set<UUID> seen = new HashSet<>();
    for (ModelCollectionQuery<T> query : queries) {
        Stream<T> queryStream = query.getCollectionStream(repository)
                                     .filter(m -> !seen.contains(m.getId()))
                                     .map(m -> {
                                         seen.add(m.getId());
                                         return m;
                                     });

        streams.add(queryStream);
        stream = Stream.concat(stream, queryStream);
    }
    return stream.onClose(() -> {
        streams.forEach(BaseStream::close);
    });
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:20,代码来源:ModelCollectionQuery.java

示例3: concatInternal

import java.util.stream.BaseStream; //导入依赖的package包/类
private static <
    T,
    T_SPLITR extends Spliterator<T>,
    T_STREAM extends BaseStream<T, T_STREAM>>
T_STREAM concatInternal(T_STREAM[] streams,
                        IntFunction<T_SPLITR[]> arrayFunction,
                        Function<T_STREAM, T_SPLITR> spliteratorFunction,
                        Function<T_SPLITR[], T_SPLITR> concatFunction,
                        BiFunction<T_SPLITR, Boolean, T_STREAM> streamFunction) {
  T_SPLITR[] spliterators = arrayFunction.apply(streams.length);
  boolean parallel = false;
  for (int i = 0; i < streams.length; i++) {
    T_STREAM inStream = streams[i];
    T_SPLITR inSpliterator = spliteratorFunction.apply(inStream);
    spliterators[i] = inSpliterator;
    parallel = parallel || inStream.isParallel();
  }
  T_SPLITR outSpliterator = concatFunction.apply(spliterators);
  T_STREAM outStream = streamFunction.apply(outSpliterator, parallel);
  return outStream.onClose(new ComposedClose(streams));
}
 
开发者ID:TechEmpower,项目名称:misc,代码行数:22,代码来源:StreamConcatenation.java

示例4: run

import java.util.stream.BaseStream; //导入依赖的package包/类
@Override
public void run() {
  int i = 0;
  BaseStream<?, ?> stream;
  while (i < streams.length) {
    stream = streams[i++];
    try {
      stream.close();
    } catch (Throwable e1) {
      while (i < streams.length) {
        stream = streams[i++];
        try {
          stream.close();
        } catch (Throwable e2) {
          // TODO: Should we wrap this in a try/catch too?
          e1.addSuppressed(e2);
        }
      }
      throw e1;
    }
  }
}
 
开发者ID:TechEmpower,项目名称:misc,代码行数:23,代码来源:StreamConcatenation.java

示例5: standardizeClass

import java.util.stream.BaseStream; //导入依赖的package包/类
private static<T> Class<?> standardizeClass(Class<T> initialClass){
    if(JsonValue.class.isAssignableFrom(initialClass))
        return JsonValue.class;
    else if( List.class.isAssignableFrom(initialClass) )
        return List.class;
    else if( BaseStream.class.isAssignableFrom(initialClass) )
        return BaseStream.class;
    else if( Set.class.isAssignableFrom(initialClass) )
        return Set.class;
    else if( initialClass.isArray() )
        return Array.class;
    else if( JsonNode.class.isAssignableFrom(initialClass) )
        return JsonNode.class;
    else if( Queue.class.isAssignableFrom(initialClass) )
        return Queue.class;
    else if( Iterator.class.isAssignableFrom(initialClass) )
        return Iterator.class;
    else if( Map.class.isAssignableFrom(initialClass) )
        return Map.class;
    else if(Iterable.class.isAssignableFrom(initialClass) )
        return Iterable.class;
    else
        return initialClass;
}
 
开发者ID:sidemash,项目名称:redson,代码行数:25,代码来源:Json.java

示例6: sequential

import java.util.stream.BaseStream; //导入依赖的package包/类
@Test
public void sequential() {
  BaseStream<?, ?> stream = this.parallelStreamSupportMock.sequential();

  verify(this.delegateMock).sequential();
  assertSame(this.parallelStreamSupportMock, stream);
}
 
开发者ID:ferstl,项目名称:parallel-stream-support,代码行数:8,代码来源:AbstractParallelStreamSupportTest.java

示例7: parallel

import java.util.stream.BaseStream; //导入依赖的package包/类
@Test
public void parallel() {
  BaseStream<?, ?> stream = this.parallelStreamSupportMock.parallel();

  verify(this.delegateMock).parallel();
  assertSame(this.parallelStreamSupportMock, stream);
}
 
开发者ID:ferstl,项目名称:parallel-stream-support,代码行数:8,代码来源:AbstractParallelStreamSupportTest.java

示例8: unordered

import java.util.stream.BaseStream; //导入依赖的package包/类
@Test
public void unordered() {
  BaseStream<?, ?> stream = this.parallelStreamSupportMock.unordered();

  verify(this.delegateMock).unordered();
  assertSame(this.parallelStreamSupportMock, stream);
}
 
开发者ID:ferstl,项目名称:parallel-stream-support,代码行数:8,代码来源:AbstractParallelStreamSupportTest.java

示例9: onClose

import java.util.stream.BaseStream; //导入依赖的package包/类
@Test
public void onClose() {
  Runnable r = () -> {};
  BaseStream<?, ?> stream = this.parallelStreamSupportMock.onClose(r);

  verify(this.delegateMock).onClose(r);
  assertSame(this.parallelStreamSupportMock, stream);
}
 
开发者ID:ferstl,项目名称:parallel-stream-support,代码行数:9,代码来源:AbstractParallelStreamSupportTest.java

示例10: StreamProducer

import java.util.stream.BaseStream; //导入依赖的package包/类
/**
 * @param stream
 *            a stream which creates new instances of type <code>T</code>.
 */
public StreamProducer(final BaseStream<T, ?> stream) {
	if (stream == null) {
		throw new IllegalArgumentException("stream may not be null");
	}
	this.stream = stream;
}
 
开发者ID:teetime-framework,项目名称:TeeTime,代码行数:11,代码来源:StreamProducer.java

示例11: combine

import java.util.stream.BaseStream; //导入依赖的package包/类
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;
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:12,代码来源:StreamContext.java

示例12: of

import java.util.stream.BaseStream; //导入依赖的package包/类
static StreamContext of(BaseStream<?, ?> stream) {
    if (stream instanceof BaseStreamEx)
        return ((BaseStreamEx<?, ?, ?, ?>) stream).context;
    if (mustCloseStream(stream))
        return new StreamContext(stream.isParallel()).onClose(stream::close);
    return stream.isParallel() ? PARALLEL : SEQUENTIAL;
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:8,代码来源:StreamContext.java

示例13: mustCloseStream

import java.util.stream.BaseStream; //导入依赖的package包/类
static boolean mustCloseStream(BaseStream<?, ?> target) {
    try {
        if (SOURCE_STAGE != null && SOURCE_CLOSE_ACTION != null
            && SOURCE_CLOSE_ACTION.get(SOURCE_STAGE.get(target)) == null)
            return false;
    } catch (IllegalArgumentException | IllegalAccessException e) {
        // ignore
    }
    return true;
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:11,代码来源:StreamExInternals.java

示例14: AbstractStreamBuilder

import java.util.stream.BaseStream; //导入依赖的package包/类
AbstractStreamBuilder(PipelineImpl<?> pipeline, StreamTerminator streamTerminator, Set<BaseStream<?, ?>> streamSet) {
    this.pipeline = requireNonNull(pipeline);
    this.streamTerminator = requireNonNull(streamTerminator);
    this.closeHandlers = new ArrayList<>();
    this.streamSet = streamSet;
    this.linkedOrConsumed = false;
}
 
开发者ID:speedment,项目名称:speedment,代码行数:8,代码来源:AbstractStreamBuilder.java

示例15: createPipeline

import java.util.stream.BaseStream; //导入依赖的package包/类
private ReferencePipeline<MockEntity> createPipeline(Action<?, ?> action) {
    @SuppressWarnings("unchecked")
    final Supplier<Stream<MockEntity>> supplier = mock(Supplier.class);
    final Stream<MockEntity> stream = MockEntityUtil.stream((int) SQL_COUNT_RESULT);
    when(supplier.get()).thenReturn(stream);
    @SuppressWarnings("unchecked")
    final ReferencePipeline<MockEntity> pipeline = new PipelineImpl<>((Supplier<BaseStream<?, ?>>) (Object) supplier);
    pipeline.add(action);
    return pipeline;
}
 
开发者ID:speedment,项目名称:speedment,代码行数:11,代码来源:SqlStreamTerminatorTest.java


注:本文中的java.util.stream.BaseStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。