There is a class User, which has its ID, name, number of sent messages and the date when these messages were sent.
Objects in the collection come from a database of this type:
ID Name Сообщения Дата 1 test3 300 2018-11-02 2 test2 228 2018-11-02 3 test3 124 2018-11-05 4 test4 24 2018-11-03 5 test3 242 2018-11-01 6 test6 334 2018-11-03 7 test7 32 2018-11-03 8 test8 22 2018-11-03 9 test9 245 2018-11-03 10 test10 145 2018-11-03 Where each line is one item in List <User>
The problem is that the records in the table are duplicated, only the date and number of messages change, and the name remains the same. And, if I want to receive message statistics for a certain period, then I will receive many different objects with the same Name. For example, in the List created according to the table above the objects with Name test3 already 3 pieces, but I would like to have one, but with the number of messages of all three.
Question: How can I delete from the List all objects that have the same Name, except for one, and add the number of deleted objects to its number of messages?