/** * Returns a {@link String} which is the concatenation of the results * of calling {@link String#valueOf(Object)} on each element of this stream * in encounter order. * * <p> * This is a <a href="package-summary.html#StreamOps">terminal</a> * operation. * * @return the result of concatenation. For empty input stream empty String * is returned. */ public String joining() { return map(String::valueOf).rawCollect(Collectors.joining()); }
/** * Returns a {@link String} which is the concatenation of the results * of calling {@link String#valueOf(Object)} on each element of this stream, * separated by the specified delimiter, in encounter order. * * <p> * This is a <a href="package-summary.html#StreamOps">terminal</a> * operation. * * @param delimiter the delimiter to be used between each element * @return the result of concatenation. For empty input stream empty String * is returned. */ public String joining(CharSequence delimiter) { return map(String::valueOf).rawCollect(Collectors.joining(delimiter)); }
/** * Returns a {@link String} which is the concatenation of the results * of calling {@link String#valueOf(Object)} on each element of this stream, * separated by the specified delimiter, with the specified prefix and * suffix in encounter order. * * <p> * This is a <a href="package-summary.html#StreamOps">terminal</a> * operation. * * @param delimiter the delimiter to be used between each element * @param prefix the sequence of characters to be used at the beginning of * the joined result * @param suffix the sequence of characters to be used at the end of the * joined result * @return the result of concatenation. For empty input stream * {@code prefix + suffix} is returned. */ public String joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix) { return map(String::valueOf).rawCollect(Collectors.joining(delimiter, prefix, suffix)); }
private static void findAppendersTypes() { final Reflections reflections = new Reflections(); types = StreamEx .of(reflections.getSubTypesOf(Appender.class)) .filter(c -> !(c.isInterface() || Modifier.isAbstract(c.getModifiers()))) .map(Class::getName) .toList(); }
@SuppressWarnings("null") private static Message generateMessage() { final String key = RandomStringUtils.randomAlphanumeric(RANDOM.nextInt(6) + 5); final String value = IntStreamEx .of(RANDOM, 100, 0, 256) .mapToObj(Integer::toHexString) .map(Messages::pad) .map(String::toUpperCase) .joining(" "); //$NON-NLS-1$ return new Message(key, value, RANDOM.nextLong(), RANDOM.nextInt(3), System.currentTimeMillis()); }
/** * Returns a collection created by provided supplier function which contains * all the elements of the collections generated by provided mapper from * each element of this stream. * * <p> * This is a <a href="package-summary.html#StreamOps">terminal</a> * operation. * * <p> * This method is equivalent to * {@code flatCollection(mapper).toCollection(supplier)}, but may work * faster. * * @param <U> the type of the elements of the resulting collection * @param <C> the type of the resulting collection * @param mapper a <a * href="package-summary.html#NonInterference">non-interfering </a>, * <a href="package-summary.html#Statelessness">stateless</a> * function to apply to each element which produces a * {@link Collection} of new values * @param supplier a supplier for the resulting collection * @return the new collection. * @since 0.3.7 */ public <U, C extends Collection<U>> C toFlatCollection(Function<? super T, ? extends Collection<U>> mapper, Supplier<C> supplier) { return map(mapper).collect(supplier, Collection::addAll, Collection::addAll); }
public static List<Long> id(final Collection<? extends DomainJpa> objects) { return objects == null ? ImmutableList.of() : StreamEx.of(objects).map(DomainJpa::getId).toList(); }
@Override @RequestMapping(value = SRV_PATH + M_R_CONFS, method = RequestMethod.GET) public List<OauthConfiguration> getServiceConfigurations() { return StreamEx .of(EnumSet.allOf(UserNetwork.class)) .map(oauth2Manager::getServiceConfiguration) .nonNull() .toList(); }
left.b = right.b; return left; }).map(pair -> mapper.apply(pair.a, pair.b));
@Nonnull public List<RoleModel> getGwtUserRoles(@Nonnull final String userId) { return StreamEx.of(userRolesService.getUserRoles(userId)).map(adapter::toGwt).toList(); }
private static <R> List<R> filter(final String query, final boolean inherited, final long limit, final Function<Logger, R> logMapper) { final String patternString = MessageFormat.format(QUERY_FORMAT, CAMEL_CASE_P03.matcher(CAMEL_CASE_P02.matcher(CAMEL_CASE_P01.matcher(query).replaceAll(CAMEL_CASE_R01)).replaceAll(CAMEL_CASE_R02)).replaceAll(CAMEL_CASE_R03)); final Pattern queryPattern = Pattern.compile(patternString, Pattern.UNICODE_CHARACTER_CLASS); return StreamEx.of(Logs.getLoggers()).parallel().filter(l -> inherited || l.getLevel() != null).filter(l -> queryPattern.matcher(l.getName()).matches()).limit(limit).map(logMapper).toList(); }
private List<IRoleMetaInfo> map(final String modelId, final Collection<Role> roles) { return StreamEx.of(roles).map(r -> (IRoleMetaInfo) loadRole(modelId, r)).toList(); }
private static Collection<EObject> findPermission(final PObject object, final EObject roleInstance, final POperation operation) { assert object.getEOperations().contains(operation); final List<EStructuralFeature> structuralFeatures = roleInstance.eClass().getEStructuralFeatures(); return StreamEx .of(structuralFeatures) .filter(f -> UamPackage.eINSTANCE.getPermission().isInstance(f.getEType()) && isOperationPermission((Permission) f.getEType(), operation)) .map(roleInstance::eGet) .map(EObject.class::cast) .toList(); }
return result; return stream.map(collector.finisher());