File tree Expand file tree Collapse file tree 1 file changed +7
-19
lines changed
vaadin-simple-grid-filter/src/main/java/software/xdev/vaadin/utl Expand file tree Collapse file tree 1 file changed +7
-19
lines changed Original file line number Diff line number Diff line change 1515 */
1616package software .xdev .vaadin .utl ;
1717
18- import java .util .ArrayList ;
19- import java .util .Comparator ;
2018import java .util .List ;
19+ import java .util .stream .Collectors ;
2120
2221import software .xdev .vaadin .model .ChipBadge ;
2322import software .xdev .vaadin .model .ChipBadgeExtension ;
@@ -41,22 +40,11 @@ public boolean equalLists(
4140 final List <ChipBadgeExtension <FilterCondition <T , ?>>> one ,
4241 final List <ChipBadgeExtension <FilterCondition <T , ?>>> two )
4342 {
44- if (one == null && two == null )
45- {
46- return true ;
47- }
48-
49- if (one == null || two == null || one .size () != two .size ())
50- {
51- return false ;
52- }
53-
54- // to avoid messing the order of the lists we will use a copy
55- final List <ChipBadgeExtension <FilterCondition <T , ?>>> oneCopy = new ArrayList <>(one );
56- final List <ChipBadgeExtension <FilterCondition <T , ?>>> twoCopy = new ArrayList <>(two );
57-
58- oneCopy .sort (Comparator .comparing (ChipBadge ::getBadgeId ));
59- twoCopy .sort (Comparator .comparing (ChipBadge ::getBadgeId ));
60- return one .equals (two );
43+ return one .stream ()
44+ .map (ChipBadge ::getBadgeId )
45+ .collect (Collectors .toSet ())
46+ .equals (two .stream ()
47+ .map (ChipBadge ::getBadgeId )
48+ .collect (Collectors .toSet ()));
6149 }
6250}
You can’t perform that action at this time.
0 commit comments