posted 11 years ago
I am looking for a solution to my below requirements.
I have a class similar to `ClassA` below
And I have two objects `(obj1, ojb2)` of `ClassA`. The requirement is to merge the two objects and remove the duplicates.
Example:
ClassA Obj1: PlanA = code=AAA, startDate=2010/12/10, endDate=2011/12/10, PlanA =code=BBB, startDate=2010/12/10 endDate=<null>
ClassA obj2: PlanA = code=AAA, startDate=2011/12/10, PlanA= code=CC, startDate=2011/12/10 endDate=<null>, PlanA= code=BBB, startDate=2010/12/10 endDate=2011/12/10,PlanA= code=DDD, startDate=2010/12/10 endDate=2011/12/10
After merging the result should look like:
ClassA obj3: PlanA=code=AAA, startDate=2011/12/10, PlanA= code=CC, startDate=2011/12/10 endDate=<null>,PlanA= code=BBB, startDate=2010/12/10 endDate=<null>,PlanA= code=DDD, startDate=2010/12/10 endDate=2011/12/10
Important Requirement:
When removing the duplicates it should also check if the endDate is present. If the endDate is present then remove that object from the list. For example, the above example has Obj1 PlanA = code=AAA, startDate=2010/12/10, endDate=2011/12/10 and Obj2 PlanA=code=AAA, startDate=2011/12/10 Now the result after merging should have code=AAA, startDate=2011/12/10
I have the below code but it is not creating the result as mentioned in the above important section. Please share with me how to accomplish the result as expected. Thanks for your help