I've a value object whose structure is like:
class MyValueObject {
String travellerName;
List<String> countryTags;
// Getters and setters
}
In this I'm maintaining a list of traveller and which countries they've visited. e.g.
Richard -> India, Poland, Australia
John -> US, Australia, Maldives
Emma -> US
Now I'm adding a filter feature, which will give list of all travellers who've visited selected countries.
List of countries will be provided as an input.
List<String> countryFilter;
This filter has a multiselect option.
The filtered result should contain both AND & OR results.
That is, if input is US & Australia, result will be:
John -> US, Australia, Maldives
Richard -> India, Poland, Australia
Emma -> US
The result should be sorted in manner that AND matches should be shown above OR matches.
Question:
How should I sort the matches?
Shall I write a comparator? If yes, some example will be very helpful.
Please suggest.
Thanks.