Questions tagged [groupingby]
77 questions
0
votes
1 answer
Issue while row hiding in Group By Nattable
I am using a nattable with rows that represent different objects, including group by objects and an another objects.
When I tried to hide row number 302, which represents an object, it is being hidden as expected. However, seeing an issue with row…

nimisha boney
- 1
- 1
0
votes
4 answers
Java Streams grouping by on two fields
I'm trying to group a data in a list and trying to add a count back to one of the fields of each object of list. Let me put some dummy example here as follows -
public class Book{
String title;
String author;
int count;
}
and there's a…

Akshay Sumbe
- 25
- 4
0
votes
1 answer
Grouping by multiple properties of custom object and generating a list of aggregated objects using Java 8
I have a class Student:
public class Student {
private String name;
private int age;
private String city;
private double salary;
private double incentive;
// getters, all-args constructor, etc.
}
And I have a list of…

prachi Kadam
- 19
- 3
0
votes
4 answers
Group the data into a Map> where Lists need to be sorted
Assume I have the following domain object:
public class MyObj {
private Long id;
private Long relationId;
private Long seq;
// getters
}
There is a list List list. I want to create a Map by grouping the data by…

Rollsbean
- 715
- 2
- 11
- 31
0
votes
0 answers
Set a sequential index within each subgroup of a List using Java 8 forEach or Stream API
I have an already sorted list of objects, and need to perform a "group by" and assign a sequence number to each object in the group.
[Essentially, I am trying to mimic the effect of a sql window function such as "seq = row_number() over (partition…

abawb
- 35
- 5
0
votes
1 answer
Java functionally read .csv using openCSV, sort table headers in ascending order, and merging duplicates using reduce()
I spent a ton of time figuring this out and wanted to share my answer. I think this is worthwhile to share because I am handling a complex table of data. This is my first time doing a java project trying to use Functional Programming wherever I can.…

TenHorizons
- 1
- 3
0
votes
2 answers
Creating a Map> from a List where each T contains a List using Stream API
I have a List of Products and every product contains a list of Ingredients.
public class Product {
private String id;
private List ingredients;
// other code
}
public class Ingredient {
private String name;
//…

seyda özdemir
- 3
- 3
0
votes
1 answer
Java 8 - Stream API - groupingby not working
I want to use the Stream API to group a list of persons by name and city.
I have following code (in Java 8):
class Person {
private String name;
private String gender;
private String city;
Person(String…

mr.burns
- 493
- 2
- 6
- 14
0
votes
2 answers
Group objects by two properties in using groupBy() in Java 8
I have a Person class like below:
public class Person {
private int id;
private String name;
private int score;
// constructor, getters, etc.
}
And I have a list of Persone objects and I want to group them into a Map.
Main…

Dattq2303
- 302
- 2
- 13
0
votes
1 answer
How to group a List of records by fields into an Object with Lists inside
I've tried to figure out how to do this but i'm stuck and i would like some help.
After having done a complex SQL Query and having assigned its result to a JPA Entity that maps this query result as if it was a view, i have this List, where each…

redbite
- 189
- 1
- 2
- 10
0
votes
1 answer
Map grouping the key based on same value
I have a Map >:
The SerialDate has two fields: Number,String
1 -> (Number1|String1, Number2|String2)
2 -> (Number1|String1, Number2|String2)
3 -> (Number3|String3)
The code is like:
Map>…

Mark PENG
- 1
- 1
0
votes
1 answer
Perfoming null-checks while collecting with Collectors.groupingBy
I have the following piece of code which groups the given entries (activities, which is Iterable) based on IDs.
For the final result, I want it to return a Map of ID to Iterables of the entries grouped by that ID.
For example: Map

NEz
- 151
- 1
- 1
- 13
0
votes
1 answer
Java Group Objects in Custom Manner
I have a list of objects that are returned from an external API and each object looks like this:
public class Item {
public String id;
public int processingType;
public String appliedToItemId;
public Float chargeAmount;
}
Objects…

z-siddiqi
- 37
- 1
- 8
0
votes
1 answer
Group a list of objects with multiple conditions
public class Student {
String name;
int age;
}
I have a list of Student objects and I need to group them according to specific logic:
Group all students whose name starts with "A"
Group all students whose name starts with "P"
Group all…

User_1940878
- 321
- 1
- 6
- 25
0
votes
1 answer
stream of list groupinngBy to map
the example code I've been given is
public Map> opzettenOverzichtBierenPerSoort() {
//TODO
return bieren.stream().collect(Collectors.groupingBy(Bier::getSoort, TreeMap::new, Collectors.toList()));
}
input is a list of…

JoshuaBrown
- 71
- 1
- 6