• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Builder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: lines

import java.util.stream.Stream.Builder; //导入依赖的package包/类
private Stream<ValuePair<Point3d, Vector3d>> lines(final long bins,
	final double sign)
{
	final Vector3d direction = getNormal(sign);
	final Vector3d t = new Vector3d(translation);
	t.scale(sign);
	final double range = 1.0 / bins;
	final Builder<ValuePair<Point3d, Vector3d>> builder = Stream.builder();
	for (int i = 0; i < bins; i++) {
		final double minC = i * range;
		for (int j = 0; j < bins; j++) {
			final double minD = j * range;
			final double c = (rng.nextDouble() * range + minC) * size - 0.5 *
				size;
			final double d = (rng.nextDouble() * range + minD) * size - 0.5 *
				size;
			final Point3d origin = createOrigin(c, d, t);
			builder.add(new ValuePair<>(origin, direction));
		}
	}
	return builder.build();
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:23,代码来源:LineGrid.java


示例2: getParameters

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@Parameters
public static <T, R> Stream<Object[]> getParameters(
		FunctionTester<T, R> input) {
	Builder<Object[]> b = Stream.builder();
	for (int i = 0; i < input.getInput().size(); i++) {
		Matcher<? super R> result = input.getResult().get(i).get();
		T param = input.getInput().get(i).get();
		String name = input.getName().get(i).get();
		if ("".equals(name)) {
			name = "Passing `" + param + "`" + " then " + result
					+ " is expected";
		}
		b.add(new Object[] { name, param, result, input.getUnderTest() });
	}
	return b.build();
}
 
开发者ID:powerunit,项目名称:powerunit,代码行数:17,代码来源:FunctionTesterImpl.java


示例3: getDatas

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@Parameters
public static <T, A, R> Stream<Object[]> getDatas(
		CollectorTester<T, A, R> input) {
	StringDescription sdChar = new StringDescription();
	input.getExpectedCharacteristics().describeTo(sdChar);
	Builder<Object[]> builder = Stream.builder();
	for (int i = 0; i < input.getInputs().size(); i++) {
		StringDescription sd = new StringDescription();
		input.getResults().get(i).describeTo(sd);
		builder.add(new Object[] {
				input.getCollectorToTest(),
				i == 0,
				input.getInputs().get(i),
				input.getResults().get(i),
				sd.toString(),
				input.getExpectedCharacteristics(),
				sdChar.toString(),
				(BiFunction<String, Object[], Boolean>) CollectorTesterImpl::filter });
	}
	return builder.build();
}
 
开发者ID:powerunit,项目名称:powerunit,代码行数:22,代码来源:CollectorTesterImpl.java


示例4: getParameters

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@Parameters
public static <T, U, R> Stream<Object[]> getParameters(
		BiFunctionTester<T, U, R> input) {
	Builder<Object[]> b = Stream.builder();
	for (int i = 0; i < input.getInput1().size(); i++) {
		Matcher<? super R> result = input.getResult().get(i).get();
		T param1 = input.getInput1().get(i).get();
		U param2 = input.getInput2().get(i).get();
		String name = input.getName().get(i).get();
		if ("".equals(name)) {
			name = "Passing `" + param1 + "` and `" + param2 + "`"
					+ " then " + result + " is expected";
		}
		b.add(new Object[] { name, param1, param2, result,
				input.getUnderTest() });
	}
	return b.build();
}
 
开发者ID:powerunit,项目名称:powerunit,代码行数:19,代码来源:BiFunctionTesterImpl.java


示例5: selectImports

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@Override
public String[] selectImports(AnnotationMetadata metadata) {
    Map<String, Object> properties = resolver.getSubProperties(EMPTY);
    Builder<Class<?>> imposts = Stream.<Class<?>>builder().add(DruidDataSourceBeanPostProcessor.class);
    imposts.add(properties.isEmpty() ? SingleDataSourceRegistrar.class : DynamicDataSourceRegistrar.class);
    return imposts.build().map(Class::getName).toArray(String[]::new);
}
 
开发者ID:drtrang,项目名称:druid-spring-boot,代码行数:8,代码来源:DruidDataSourceConfiguration.java


示例6: polygonsFrom

import java.util.stream.Stream.Builder; //导入依赖的package包/类
public static Stream<Polygon> polygonsFrom(Geometry g) {
    if (g instanceof Polygon) {
        return Stream.of((Polygon) g);
    }
    else if (g instanceof MultiPolygon) {
        Builder<Polygon> builder = Stream.builder();
        for (int i = 0; i < g.getNumGeometries(); i++) {
            builder.add((Polygon) g.getGeometryN(i));
        }
        return builder.build();
    }
    return Stream.empty();
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:14,代码来源:PolygonsUtils.java


示例7: splitDims

import java.util.stream.Stream.Builder; //导入依赖的package包/类
/**
 * Recursively calls {@link #applySplit(ImgPlus, List)} to split the
 * hyperstack into subspaces.
 *
 * @param hyperstack an n-dimensional image
 * @param splitIndices the indices of the axes in the hyperstack used for
 *          splitting
 * @param splitIndex the i in splitIndices[i] currently used. Start from the
 *          last index
 * @param meta the metadata describing the position of the next subspace
 * @param splitCoordinates the (dimension, position) pairs describing the
 *          current split
 * @param subscripts the subscripts of the axes see
 * @param subspaces A builder for the stream of all the subspaces formed
 */
private static <T extends RealType<T> & NativeType<T>> void splitDims(
	final ImgPlus<T> hyperstack, final int[] splitIndices, final int splitIndex,
	final HyperAxisMeta[] meta,
	final List<ValuePair<IntType, LongType>> splitCoordinates,
	final long[] subscripts, final Builder<Subspace<T>> subspaces)
{
	if (splitIndex < 0) {
		final RandomAccessibleInterval<T> subspace = applySplit(hyperstack,
			splitCoordinates);
		if (!isEmptySubspace(subspace)) {
			subspaces.add(new Subspace<>(subspace, meta));
		}
	}
	else {
		final int splitDimension = splitIndices[splitIndex];
		final AxisType type = hyperstack.axis(splitDimension).type();
		final long subscript = subscripts[splitIndex];
		final long size = hyperstack.dimension(splitDimension);
		final ValuePair<IntType, LongType> pair = new ValuePair<>(new IntType(
			splitDimension), new LongType());
		for (long position = 0; position < size; position++) {
			pair.b.set(position);
			splitCoordinates.add(pair);
			meta[splitIndex] = new HyperAxisMeta(type, position, subscript);
			splitDims(hyperstack, splitIndices, splitIndex - 1, meta,
				splitCoordinates, subscripts, subspaces);
			splitCoordinates.remove(pair);
		}
	}
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:46,代码来源:HyperstackUtils.java


示例8: parallelStreamWithBuilder

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@Test
public void parallelStreamWithBuilder() {
  Builder<String> builder = Stream.builder();
  builder.accept("a");
  Stream<String> stream = ParallelStreamSupport.parallelStream(builder, this.workerPool);

  assertThat(stream, instanceOf(ParallelStreamSupport.class));
  assertTrue(stream.isParallel());
  assertEquals(Optional.of("a"), stream.findAny());
}
 
开发者ID:ferstl,项目名称:parallel-stream-support,代码行数:11,代码来源:ParallelStreamSupportTest.java


示例9: mapExistingResourceParams

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
protected static Map<MultiKey<Serializable>, ResourceParam<?>> mapExistingResourceParams(SdcctResource entity) {
    Map<MultiKey<Serializable>, ResourceParam<?>> existingResourceParams = new LinkedHashMap<>();
    Builder<Serializable> existingResourceParamKeyStreamBuilder;
    TermResourceParam<?> existingTermResourceParam;

    for (ResourceParam<?> existingResourceParam : IteratorUtils.asIterable(iterateExistingResourceParams(entity))) {
        if (existingResourceParam.isMeta()) {
            continue;
        }

        (existingResourceParamKeyStreamBuilder = Stream.builder()).add(existingResourceParam.getName());

        if (existingResourceParam instanceof TermResourceParam) {
            existingResourceParamKeyStreamBuilder.add((existingTermResourceParam = ((TermResourceParam<?>) existingResourceParam)).getCodeSystemUri());
            existingResourceParamKeyStreamBuilder.add(existingTermResourceParam.getCodeSystemVersion());

            if (existingResourceParam instanceof QuantityResourceParam) {
                existingResourceParamKeyStreamBuilder.add(((QuantityResourceParam) existingTermResourceParam).getUnits());
            }

            existingResourceParamKeyStreamBuilder.add(existingTermResourceParam.getDisplayName());
        }

        existingResourceParamKeyStreamBuilder.add(existingResourceParam.getValue());

        existingResourceParams.put(new MultiKey<>(existingResourceParamKeyStreamBuilder.build().toArray(Serializable[]::new)), existingResourceParam);
    }

    return existingResourceParams;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:32,代码来源:AbstractResourceParamProcessor.java


示例10: findAuthors

import java.util.stream.Stream.Builder; //导入依赖的package包/类
public Stream<String> findAuthors() {
    final Builder<String> authors = Stream.builder();
    for (PositionedData<Directive> directive : directives) {
        if ( "author".equals(directive.data.name.toLowerCase()) ) {
            authors.add(directive.data.value);
        }
    }
    return authors.build();
}
 
开发者ID:kawane,项目名称:songbook,代码行数:10,代码来源:Song.java


示例11: getParameters

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@Parameters
public static Stream<Object[]> getParameters(PatternTester input) {
	Builder<Object[]> builder = Stream.builder();
	for (int i = 0; i < input.getInputs().size(); i++) {
		builder.add(new Object[] { input.getUnderTest(),
				input.getInputs().get(i), input.getExpectedResult().get(i),
				input.getHavingGroup().get(i),
				input.getExpectedGroup().get(i),
				input.getUnderTest().pattern() });
	}
	return builder.build();
}
 
开发者ID:powerunit,项目名称:powerunit,代码行数:13,代码来源:PatternTesterImpl.java


示例12: getParameter

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@Parameters
public static Stream<Object[]> getParameter(MatcherTester input) {
	Builder<Object[]> builder = Stream.builder();
	for (int i = 0; i < input.getExpectedGroup().size(); i++) {
		StringDescription sd = new StringDescription();
		input.getExpectedGroup().get(i).describeTo(sd);
		builder.add(new Object[] { input.getMatcher(),
				input.getMatcher().pattern().pattern(), input.getInput(),
				input.getHavingGroup().get(i),
				input.getExpectedGroup().get(i), sd.toString() });
	}
	return builder.build();
}
 
开发者ID:powerunit,项目名称:powerunit,代码行数:14,代码来源:MatcherTesterImpl.java


示例13: createCompiledCode

import java.util.stream.Stream.Builder; //导入依赖的package包/类
public static HotSpotCompiledCode createCompiledCode(CodeCacheProvider codeCache, ResolvedJavaMethod method, HotSpotCompilationRequest compRequest, CompilationResult compResult) {
    String name = compResult.getName();

    byte[] targetCode = compResult.getTargetCode();
    int targetCodeSize = compResult.getTargetCodeSize();

    Site[] sites = getSortedSites(codeCache, compResult);

    Assumption[] assumptions = compResult.getAssumptions();

    ResolvedJavaMethod[] methods = compResult.getMethods();

    List<CodeAnnotation> annotations = compResult.getAnnotations();
    Comment[] comments = new Comment[annotations.size()];
    if (!annotations.isEmpty()) {
        for (int i = 0; i < comments.length; i++) {
            CodeAnnotation annotation = annotations.get(i);
            String text;
            if (annotation instanceof CodeComment) {
                CodeComment codeComment = (CodeComment) annotation;
                text = codeComment.value;
            } else if (annotation instanceof JumpTable) {
                JumpTable jumpTable = (JumpTable) annotation;
                text = "JumpTable [" + jumpTable.low + " .. " + jumpTable.high + "]";
            } else {
                text = annotation.toString();
            }
            comments[i] = new Comment(annotation.position, text);
        }
    }

    DataSection data = compResult.getDataSection();
    byte[] dataSection = new byte[data.getSectionSize()];

    ByteBuffer buffer = ByteBuffer.wrap(dataSection).order(ByteOrder.nativeOrder());
    Builder<DataPatch> patchBuilder = Stream.builder();
    data.buildDataSection(buffer, vmConstant -> {
        patchBuilder.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant)));
    });

    int dataSectionAlignment = data.getSectionAlignment();
    DataPatch[] dataSectionPatches = patchBuilder.build().toArray(len -> new DataPatch[len]);

    int totalFrameSize = compResult.getTotalFrameSize();
    StackSlot customStackArea = compResult.getCustomStackArea();
    boolean isImmutablePIC = compResult.isImmutablePIC();

    if (method instanceof HotSpotResolvedJavaMethod) {
        HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method;
        int entryBCI = compResult.getEntryBCI();
        boolean hasUnsafeAccess = compResult.hasUnsafeAccess();

        int id;
        long jvmciEnv;
        if (compRequest != null) {
            id = compRequest.getId();
            jvmciEnv = compRequest.getJvmciEnv();
        } else {
            id = hsMethod.allocateCompileId(entryBCI);
            jvmciEnv = 0L;
        }
        return new HotSpotCompiledNmethod(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC,
                        totalFrameSize, customStackArea, hsMethod, entryBCI, id, jvmciEnv, hasUnsafeAccess);
    } else {
        return new HotSpotCompiledCode(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC,
                        totalFrameSize, customStackArea);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:69,代码来源:HotSpotCompiledCodeBuilder.java


示例14: findSplitAxisIndices

import java.util.stream.Stream.Builder; //导入依赖的package包/类
/**
 * Splits the hyperstack into subspaces defined by the given axes.
 * <p>
 * If all the given axis types are not found in the hyperstack, gives
 * subspaces of the found types. If none of the types are found, returns an
 * empty stream. For example, if you want to split a {X, Y, C, T} hyperstack
 * into {X, Y, Z}, returns all the {X, Y} subspaces.
 * </p>
 * <p>
 * NB Assumes that the given {@link ImgPlus} has the necessary metadata, i.e.
 * its {@link CalibratedAxis} have {@link AxisType}.
 * </p>
 *
 * @param hyperStack an N-dimensional image.
 * @param <T> type of the elements in the image.
 * @param subspaceTypes the types of the axis in the desired subspace.
 * @return a stream of all the subspaces found.
 */
public static <T extends RealType<T> & NativeType<T>> Stream<Subspace<T>>
	splitSubspaces(final ImgPlus<T> hyperStack, List<AxisType> subspaceTypes)
{
	if (subspaceTypes == null || subspaceTypes.isEmpty()) {
		return Stream.empty();
	}
	final Builder<Subspace<T>> builder = Stream.builder();
	final int[] splitIndices = findSplitAxisIndices(hyperStack, subspaceTypes);
	final long[] typeSubscripts = mapTypeSubscripts(hyperStack, splitIndices);
	final int numSplits = splitIndices.length;
	final HyperAxisMeta[] subspaceMeta = new HyperAxisMeta[numSplits];
	final List<ValuePair<IntType, LongType>> split = new ArrayList<>();
	splitDims(hyperStack, splitIndices, numSplits - 1, subspaceMeta, split,
		typeSubscripts, builder);
	return builder.build();
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:35,代码来源:HyperstackUtils.java


示例15: parallelStreamWithNullBuilder

import java.util.stream.Stream.Builder; //导入依赖的package包/类
@Test(expected = NullPointerException.class)
public void parallelStreamWithNullBuilder() {
  Builder<String> builder = null;
  ParallelStreamSupport.parallelStream(builder, this.workerPool);
}
 
开发者ID:ferstl,项目名称:parallel-stream-support,代码行数:6,代码来源:ParallelStreamSupportTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UnauthorizedServiceException类代码示例发布时间:2022-05-22
下一篇:
Java MathUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap