Problem : I have a utility function which takes in a generic list to remove duplicates, Now when I use it for List<String> the match should case insensitive. The code uses streams (Java 8+) and i want to keep it that way.
Note : code is in JAVA 8+
Code :
public static <T> List<T> removeDuplicates(List<T> inputList) {
    List<T> result = null;
    if (inputList != null && inputList.size() > 0) {
        result = inputList.parallelStream().distinct().collect(Collectors.toList());
    }
    return result;
}
EG:
List<String> inputList = new ArrayList<String>();
inputList.add("a");
inputList.add("A");
inputList.add("abc");
inputList.add("ABC");
inputList.add("c");
When we call removeDuplicates(inputList) and print it
Values:
 a
 abc
 c
I don't really care if it choose ABC over abc or A over a but it should be there only once.
Is there an elegant way of solving this issue without doing an instanceof check ?
 
     
     
    