I wish to extend DefaultGlazedListsFilterStrategy so that I can apply a filter strategy such that the 'null' in my table are ignored during numeric comparison. In the following table, the null values cause a problem in numeric comparison. Any filter comparator cannot work properly with null values since they always have to be accounted for during comparison and hence incorrectly figure in the filtered list. NullsFirstComparator and NullsLastComparator were both incorrect in one of the cases.
Filtered nattable with null values
As mentioned, I tried DefaultGlazedListsFilterStrategy but could not filter out the 'null' values which appear in my table.
-edit-
The issue lies in the numeric comparison for column number 3 (Size in bytes) in the image. In the image, entries in the column below 2960 are null. I have used a DefaultComparator as the FilterComparator.
In a scenario where a 'null' is compared to 1000( for example row number 2), we get a result of -1 as per the DefaultComparator implementation, resulting in that null object being a true match. As per my Nattable design, rows 2-17 are actually a children of row 1 (tree structure). This in turn results in row 1 being automatically shown in the resulting list since it is the parent. Thus the filtering seems broken because 2960 being greater than 1000 is still shown in the resulting table.
I am limited by the filter comparator in this case, I could go for Comparator.nullsFirst(new DefaultComparator()) and Comparator.nullsLast(new DefaultComparator()), but both of them would break down when the comparison sign is reversed (each one would only work for either <'value' or >'value').
Ideally, I dont want any row with a null value to even be considered for filtering since the null value eventually breaks down the numeric filtering.
Thus I thought of implementing a filterstrategy which would ignore such null values altogether.
You need to implement and register a custom Filter comparator for your special case. The default comparator is actually only a comparison of string representations.