本文整理汇总了Java中java.util.stream.Stream.Builder.add方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.add方法的具体用法?Java Builder.add怎么用?Java Builder.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.stream.Stream.Builder
的用法示例。
在下文中一共展示了Builder.add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
}
}
示例8: 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;
}
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}