I have this code:
Map<List<Object>, Long> collector = root.getReports().stream().collect(
Collectors.groupingBy(r -> Arrays.asList(i.X(), i.Y(), i.Z(), i.A()), Collectors.counting()));
for(Entry<Object, Long> entry : collector.entrySet())
System.out.println(String.format("%s = %s", entry.getKey(), entry.getValue()));
Which basically produces this:
[16292, 141, 6, 100] = 2
[16288, 250, 59, 500] = 14
[16286, 250, 91, 50] = 4
[16287, 250, 91, 60] = 29
[16286, 250, 91, 80] = 10
[16293, 141, 6, 100] = 3
[16282, 079, 116, 50] = 9
...
I need to to put this results into a custom class, this one:
@EqualsAndHashCode @ToString
public class CustomReport implements Serializable {
private static final long serialVersionUID = 2074900904056768029L;
@Getter @Setter
private Integer x, y, z;
@Getter @Setter
private String a;
@Getter @Setter
private Long result;
}
There's a way to do this without go through all the list and doing it manually?
, Integer>` to `CustomReport`.
– Turing85 Sep 04 '20 at 19:33