
Jérôme
Tech Lead/Architecte
onepoint BDX
@jtama
public class Quizz {
public static void main(String[] args) {
getPeople()
.map(person -> person.getName())
.toList();
}
}
La ligne 4 est exécutée :
10 fois
1 fois
Non
It depends
public class Quizz {
public static void main(String[] args) {
getPeople()
.map(person -> person.getName());
}
}
La fonction passée en paramètre de la méthode map
est exécutée :
10 fois
1 fois
Non
public class Quizz {
public static void main(String[] args) {
getPeople()
.map(person -> person.getName())
.count();
}
}
La fonction passée en paramètre de la méthode map
est exécutée :
10 fois
1 fois
Non
Intermédiaires, Finales.
L’invocation d’une opération finale est le déclencheur de l’exécution du pipeline.
Certaines opérations finales sont des courts-circuits.
♾️
Collector collector;
Collectors.groupingBy(...);
stream.collect(collector);
Gatherer gatherer;
Gatherers.windowFixed(...);
stream.gather(gatherer);
package java.util.stream;
public interface Gatherer<T, A, R> {
default Supplier<A> initializer();
Integrator<A, T, R> integrator();
default BinaryOperator<A> combiner();
default BiConsumer<A, Downstream<? super R>> finisher();
}
Oui, ça peut servir à quelque chose !
N’en abusez pas quand même…
Le dépôt github :
Feedback :