I have a collection of Objects (Pos) with this model :
public class Pos { private String beforeChangement; private String type; private String afterChangement; } The list of objects is like this :
[ Pos(beforeChangement=Découvrez, type=VER, afterChangement=découvrir), Pos(beforeChangement=un, type=DET, afterChangement=un), Pos(beforeChangement=large, type=ADJ, afterChangement=large), Pos(beforeChangement=., type=SENT, afterChangement=.), Pos(beforeChangement=Livraison, type=NOM, afterChangement=livraison), Pos(beforeChangement=et, type=KON, afterChangement=et), Pos(beforeChangement=retour, type=NOM, afterChangement=retour), Pos(beforeChangement=., type=SENT, afterChangement=.), Pos(beforeChangement=achetez, type=VER, afterChangement=acheter), Pos(beforeChangement=gratuitement, type=ADV, afterChangement=gratuitement), Pos(beforeChangement=., type=SENT, afterChangement=.), Pos(beforeChangement=allez, type=VER, afterChangement=aller), Pos(beforeChangement=faites, type=VER, afterChangement=faire), Pos(beforeChangement=vite, type=ADV, afterChangement=vite), Pos(beforeChangement=chers, type=ADJ, afterChangement=cher), Pos(beforeChangement=clients, type=NOM, afterChangement=client)] Pos(beforeChangement=., type=SENT, afterChangement=.) ] I want to split this List of Objects by the the field of beforeChangement or afterChangement == "." to have this format (A List of List) List<List<SOP>> :
[ [Pos(beforeChangement=Découvrez, type=VER, afterChangement=découvrir), Pos(beforeChangement=un, type=DET, afterChangement=un), Pos(beforeChangement=large, type=ADJ, afterChangement=large)], [Pos(beforeChangement=Livraison, type=NOM, afterChangement=livraison), Pos(beforeChangement=et, type=KON, afterChangement=et), Pos(beforeChangement=retour, type=NOM, afterChangement=retour)], [Pos(beforeChangement=achetez, type=VER, afterChangement=acheter), Pos(beforeChangement=gratuitement, type=ADV, afterChangement=gratuitement)], [Pos(beforeChangement=allez, type=VER, afterChangement=aller), Pos(beforeChangement=faites, type=VER, afterChangement=faire), Pos(beforeChangement=vite, type=ADV, afterChangement=vite), Pos(beforeChangement=chers, type=ADJ, afterChangement=cher), Pos(beforeChangement=clients, type=NOM, afterChangement=client)] ] Is like performing an inverse flatMap to have a List of Array or List (Chunks) after splitting by a field of object that is the String "."
do you have any idea about how to do it using Streams ?
Thank you guys