I am looing to ensure order in parallel streams based on some field value. Maybe I will introduce some abstract example:
Let's say we have class User
@Lombok.Data()
class User {
private String firstName;
private String lastName;
private int someValue;
private int priority;
}
and we have list of these Users:
List<User> users = someInitUsersFunction();
I want to force parellel stream to process every user per priority, let's say we have 100 users with 0 priority, 100 users with 1 priority and 100 users with 2 priority.
I want to start process users with priority 2 only when priority 1 is done and when priority 0 is done.
I think
mvn install -T 4
might be the approach I am looking for (the first build independent modules). Is it possible to do this in java streams? Also use alternatives is possible.
My approach is to divide to specific list by priority then process list by list