Lets assume I have a list List<Foo> mylist = parseFromCSV();
Where
parseFromCSV()
returns a list of object of Foo class. Foo class has her private attributes:
private mailId;
private status;
... getters and setters...
A Possibly pair of objects in
mylist: [{MailId=100, Status=BOUNCED, [email protected]},{MailId=100, Status=OPENED, [email protected]}, {MailId=200, Status=CLICKED, EMAIL = [email protected]}, {MailId=100, Status=HARDBOUNCED, EMAIL = [email protected]}]
I can indeed have duplicates in my list because the objects listed represents the CSV lines parsed into Java Objects. Each MailId has multiple different possible status of feedback.
What I am interested in, is to retrieve only the "important" status in my set of possible statuses for one MailId and persist into my database.
OPENED > CLICKED > HARDBOUNCED > BOUNCED (priority of the statuses).
In my example: for MailId= 100 I will only persist the OPENED status into my status column in database.
What will be a good way of achieving this? Should I create a new List (Set?) containing each pair filtered of {MailId, Status(Prioritized)}, ... {MailIdN, StatusN(Prioritized)...} ? Can we add priority on String using Enumerations or making a new comparator for my objects of class Foo?
The persisting operations into mysql database using hibernate should look like this:
persistStatusIntoTable(String MailId, String Status(Taken only status based on priority))
Thanks to all of your help !