Now on comparing with the ArrayList of similar objects, results should be an ArrayList of all the objects which have {---,---,A,B,C} as the pattern. Means all the objects which have A,B,C will be added to the new list.
Try 1: I tried by individually comparing the values by looping through the entire list, which I realised is not a good solution and also I got stuck in lot of loops with several permutation/combination of possible dynBeanObject.
Try 2:I have an idea of using Comparator, but it will require to write comparator for every field.
But as the bean object is dynamic, so writing a comparator for every filed is not a good solution. There can be several beans...and each bean will have several fields.
Moreover I would like to create a generic solution which can be re-used. Also at runtime, I will neither have idea about the the bean class associated with dynamic bean object and the ArrayList of objects.
Paul Clapham wrote:If you have "degrees" of similarity -- i.e. one object can be "more similar" to an object than a second object is -- then an "equals" method isn't going to be of any use. You want a "similarity" method which returns a number between 0 and 1, or between 1 and 100, or between negative infinity and positive infinity, whatever the possibilities are.
Then you need a method which scans the list and picks the member X for which similarity(X, Base) is maximized.
Don't get me started about those stupid light bulbs. |