@Override default Stream<Stream<T>> combinations() { return Stream.rangeClosed(0, length()).map(this::combinations).flatMap(Function.identity()); }
/** * Recursively builds a non-empty {@code Tree}, starting with the given {@code seed} value and proceeding in depth-first order. * <p> * The children of a node are created by * <ol> * <li>applying the {@code descend} function to the node value</li> * <li>calling this method recursively by using each derived child value as new seed (in iteration order).</li> * </ol> * <p> * Example: * <pre>{@code * // = (1 (2 4 5) 3) * Tree.recurse(1, i -> * (i == 1) ? List.of(2, 3) : * (i == 2) ? List.(4, 5) : * List.empty() * ).toLispString(); * }</pre> * * @param seed The start value for the Tree * @param descend A function to calculate the child values * @param <T> Value type * @return a new, non-empty {@code Tree} instance * @throws NullPointerException if {@code descend} is null */ static <T> Node<T> recurse(T seed, Function<? super T, ? extends Iterable<? extends T>> descend) { Objects.requireNonNull(descend, "descend is null"); return Tree.of(seed, Stream.of(seed).flatMap(descend).map(children -> recurse(children, descend))); }
static <T> Stream<Stream<T>> apply(Stream<T> elements, int k) { if (k == 0) { return Stream.of(Stream.empty()); } else { return elements.zipWithIndex().flatMap( t -> apply(elements.drop(t._2 + 1), (k - 1)).map((Stream<T> c) -> c.prepend(t._1)) ); } } }
@Override public final <A extends Annotation> Iterable<Declaration<A>> declarations(Class<A> type) { return Stream.ofAll(manifests) .flatMap(m -> m.declarations(type)); } }
@Override default Stream<Stream<T>> combinations() { return Stream.rangeClosed(0, length()).map(this::combinations).flatMap(Function.identity()); }
/** * Recursively builds a non-empty {@code Tree}, starting with the given {@code seed} value and proceeding in depth-first order. * <p> * The children of a node are created by * <ol> * <li>applying the {@code descend} function to the node value</li> * <li>calling this method recursively by using each derived child value as new seed (in iteration order).</li> * </ol> * <p> * Example: * <pre>{@code * // = (1 (2 4 5) 3) * Tree.recurse(1, i -> * (i == 1) ? List.of(2, 3) : * (i == 2) ? List.(4, 5) : * List.empty() * ).toLispString(); * }</pre> * * @param seed The start value for the Tree * @param descend A function to calculate the child values * @param <T> Value type * @return a new, non-empty {@code Tree} instance * @throws NullPointerException if {@code descend} is null */ static <T> Node<T> recurse(T seed, Function<? super T, ? extends Iterable<? extends T>> descend) { Objects.requireNonNull(descend, "descend is null"); return Tree.of(seed, Stream.of(seed).flatMap(descend).map(children -> recurse(children, descend))); }
static int vavrStream() { return io.vavr.collection.Stream.range(0, COUNT) .flatMap(i -> io.vavr.collection.Stream.range(i, i + BIND)) .filter(i -> i >= FILTER) .map(i -> i + 1) .foldLeft(0, (i, a) -> i + a); }
/** * Deserializes the credited works matching the {@link #CREDITS_RESOURCES_PATH} location pattern. * * @param objectMapper The object mapper used for deserialization * @param pmpr The {@link PathMatchingResourcePatternResolver} used for location pattern matching * * @return The list of deserialized credits files */ private static List<CreditedWork> loadCreditsFiles( final ObjectMapper objectMapper, final PathMatchingResourcePatternResolver pmpr ) { return Try.of(() -> pmpr.getResources(CREDITS_RESOURCES_PATH)) .toStream() .flatMap(Stream::of) .map(unchecked(Resource::getInputStream)) .map(unchecked(cis -> objectMapper.readValue(cis, CreditedWork.class))) .toJavaList(); }
static <T> Stream<Stream<T>> apply(Stream<T> elements, int k) { if (k == 0) { return Stream.of(Stream.empty()); } else { return elements.zipWithIndex().flatMap( t -> apply(elements.drop(t._2 + 1), (k - 1)).map((Stream<T> c) -> c.prepend(t._1)) ); } } }
final Iterable<ClassName> baseScalars = Stream .of(declaration.annotation().has()) .flatMap( n -> Stream .ofAll(manifest.declarations(Scalar.class))