本文整理了Java中java.util.stream.Stream.concat()
方法的一些代码示例,展示了Stream.concat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stream.concat()
方法的具体详情如下:
包路径:java.util.stream.Stream
类名称:Stream
方法名:concat
暂无
代码示例来源:origin: google/guava
@Override
public Stream<E> stream() {
return Stream.concat(set1.stream(), set2.stream().filter(e -> !set1.contains(e)));
}
代码示例来源:origin: apache/kafka
public static <T> List<T> concatLists(List<T> left, List<T> right, Function<List<T>, List<T>> finisher) {
return Stream.concat(left.stream(), right.stream())
.collect(Collectors.collectingAndThen(Collectors.toList(), finisher));
}
代码示例来源:origin: prestodb/presto
private static <T> Set<T> union(Set<T> set1, Set<T> set2)
{
return Stream.concat(set1.stream(), set2.stream())
.collect(toSet());
}
代码示例来源:origin: spring-projects/spring-data-redis
@SuppressWarnings("Convert2MethodRef")
protected ByteBuffer[] keysAndArgs(RedisElementWriter argsWriter, List<K> keys, List<?> args) {
return Stream.concat(keys.stream().map(t -> keySerializer().getWriter().write(t)),
args.stream().map(t -> argsWriter.write(t))).toArray(size -> new ByteBuffer[size]);
}
代码示例来源:origin: SonarSource/sonarqube
private void printSensors(Collection<ModuleSensorWrapper> moduleSensors, Collection<ModuleSensorWrapper> globalSensors) {
String sensors = Stream
.concat(moduleSensors.stream(), globalSensors.stream())
.map(Object::toString)
.collect(Collectors.joining(" -> "));
LOG.debug("Sensors : {}", sensors);
}
代码示例来源:origin: Netflix/zuul
.map(String::trim)
.filter(blank.negate());
.map(String::trim)
.filter(blank.negate())
.flatMap(packageName -> cp.getTopLevelClasses(packageName).stream())
.map(ClassPath.ClassInfo::load)
.filter(ZuulFilter.class::isAssignableFrom)
.map(Class::getCanonicalName);
String[] filterClassNames = Stream.concat(classNameStream, packageStream).toArray(String[]::new);
if (filterClassNames.length != 0) {
LOG.info("Using filter classnames: ");
代码示例来源:origin: prestodb/presto
public Optional<Column> getColumn(String name)
{
return Stream.concat(partitionColumns.stream(), dataColumns.stream())
.filter(column -> column.getName().equals(name))
.findFirst();
}
代码示例来源:origin: SonarSource/sonarqube
private List<String> searchEditableProfiles(DbSession dbSession, OrganizationDto organization) {
if (!userSession.isLoggedIn()) {
return emptyList();
}
String login = userSession.getLogin();
UserDto user = dbClient.userDao().selectActiveUserByLogin(dbSession, login);
checkState(user != null, "User with login '%s' is not found'", login);
return Stream.concat(
dbClient.qProfileEditUsersDao().selectQProfileUuidsByOrganizationAndUser(dbSession, organization, user).stream(),
dbClient.qProfileEditGroupsDao().selectQProfileUuidsByOrganizationAndGroups(dbSession, organization, userSession.getGroups()).stream())
.collect(toList());
}
代码示例来源:origin: SonarSource/sonarqube
private static List<QProfileDto> merge(QProfileDto profile, Collection<QProfileDto> descendants) {
return Stream.concat(Stream.of(profile), descendants.stream())
.collect(MoreCollectors.toList(descendants.size() + 1));
}
}
代码示例来源:origin: SonarSource/sonarqube
private static HighlightBuilder.Field createHighlighterField() {
HighlightBuilder.Field field = new HighlightBuilder.Field(FIELD_NAME);
field.highlighterType("fvh");
field.matchedFields(
Stream.concat(
Stream.of(FIELD_NAME),
Arrays
.stream(NAME_ANALYZERS)
.map(a -> a.subField(FIELD_NAME)))
.toArray(String[]::new));
return field;
}
代码示例来源:origin: SonarSource/sonarqube
private static <RAW extends Trackable, BASE extends Trackable> List<BASE> concatIssues(
NonClosedTracking<RAW, BASE> nonClosedTracking, ClosedTracking<RAW, BASE> closedTracking) {
Collection<BASE> nonClosedIssues = nonClosedTracking.getBaseInput().getIssues();
Collection<BASE> closeIssues = closedTracking.getBaseInput().getIssues();
return Stream.concat(nonClosedIssues.stream(), closeIssues.stream())
.collect(toList(nonClosedIssues.size() + closeIssues.size()));
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void deleteIndexes(String name, String... otherNames) {
GetMappingsResponse mappings = client.nativeClient().admin().indices().prepareGetMappings("_all").get();
Set<String> existingIndices = Sets.newHashSet(mappings.mappings().keysIt());
Stream.concat(Stream.of(name), Arrays.stream(otherNames))
.distinct()
.filter(existingIndices::contains)
.forEach(this::deleteIndex);
}
代码示例来源:origin: SonarSource/sonarqube
private String[] exclusions(Function<String, String[]> configProvider, String globalExclusionsProperty, String exclusionsProperty) {
String[] globalExclusions = configProvider.apply(globalExclusionsProperty);
String[] exclusions = configProvider.apply(exclusionsProperty);
return Stream.concat(Arrays.stream(globalExclusions), Arrays.stream(exclusions))
.map(StringUtils::trim)
.toArray(String[]::new);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void checkNode_returns_YELLOW_status_if_only_GREEN_and_at_least_one_YELLOW_statuses_returned_by_NodeHealthCheck() {
List<Health.Status> statuses = new ArrayList<>();
Stream.concat(
IntStream.range(0, 1 + random.nextInt(20)).mapToObj(i -> YELLOW), // at least 1 YELLOW
IntStream.range(0, random.nextInt(20)).mapToObj(i -> GREEN)).forEach(statuses::add); // between 0 and 19 GREEN
Collections.shuffle(statuses);
HealthCheckerImpl underTest = newNodeHealthCheckerImpl(statuses.stream());
assertThat(underTest.checkNode().getStatus())
.describedAs("%s should have been computed from %s statuses", YELLOW, statuses)
.isEqualTo(YELLOW);
}
代码示例来源:origin: biezhi/30-seconds-of-java8
public static <T> T[] symmetricDifference(T[] first, T[] second) {
Set<T> sA = new HashSet<>(Arrays.asList(first));
Set<T> sB = new HashSet<>(Arrays.asList(second));
return Stream.concat(
Arrays.stream(first).filter(a -> !sB.contains(a)),
Arrays.stream(second).filter(b -> !sA.contains(b))
).toArray(i -> (T[]) Arrays.copyOf(new Object[0], i, first.getClass()));
}
代码示例来源:origin: SonarSource/sonarqube
public UriReader(SchemeProcessor[] processors) {
Stream.concat(Stream.of(new FileProcessor()), Arrays.stream(processors)).forEach(processor -> {
for (String scheme : processor.getSupportedSchemes()) {
processorsByScheme.put(scheme.toLowerCase(Locale.ENGLISH), processor);
}
});
}
代码示例来源:origin: prestodb/presto
@Override
public String toString()
{
List<String> allConstraints = concat(
typeVariableConstraints.stream().map(TypeVariableConstraint::toString),
longVariableConstraints.stream().map(LongVariableConstraint::toString))
.collect(Collectors.toList());
return name + (allConstraints.isEmpty() ? "" : "<" + Joiner.on(",").join(allConstraints) + ">") + "(" + Joiner.on(",").join(argumentTypes) + "):" + returnType;
}
代码示例来源:origin: prestodb/presto
private static <T> Set<T> union(Set<T> set1, Set<T> set2)
{
return Stream.concat(set1.stream(), set2.stream())
.collect(toSet());
}
代码示例来源:origin: eclipse-vertx/vert.x
public static KeyStoreHelper create(VertxInternal vertx, TrustOptions options) throws Exception {
if (options instanceof KeyCertOptions) {
return create(vertx, (KeyCertOptions) options);
} else if (options instanceof PemTrustOptions) {
PemTrustOptions trustOptions = (PemTrustOptions) options;
Stream<Buffer> certValues = trustOptions.
getCertPaths().
stream().
map(path -> vertx.resolveFile(path).getAbsolutePath()).
map(vertx.fileSystem()::readFileBlocking);
certValues = Stream.concat(certValues, trustOptions.getCertValues().stream());
return new KeyStoreHelper(loadCA(certValues), null);
} else {
return null;
}
}
代码示例来源:origin: Netflix/zuul
.map(String::trim)
.filter(blank.negate());
.map(String::trim)
.filter(blank.negate())
.flatMap(packageName -> cp.getTopLevelClasses(packageName).stream())
.map(ClassPath.ClassInfo::load)
.filter(ZuulFilter.class::isAssignableFrom)
.map(Class::getCanonicalName);
String[] filterClassNames = Stream.concat(classNameStream, packageStream).toArray(String[]::new);
if (filterClassNames.length != 0) {
LOG.info("Using filter classnames: ");
内容来源于网络,如有侵权,请联系作者删除!