Skip to content

Commit

Permalink
Update FilterComponentUtl.java
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesRabauer committed Nov 12, 2024
1 parent 6b2ae19 commit fe4f39b
Showing 1 changed file with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
*/
package software.xdev.vaadin.utl;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import software.xdev.vaadin.model.ChipBadge;
import software.xdev.vaadin.model.ChipBadgeExtension;
Expand All @@ -41,22 +40,11 @@ public boolean equalLists(
final List<ChipBadgeExtension<FilterCondition<T, ?>>> one,
final List<ChipBadgeExtension<FilterCondition<T, ?>>> two)
{
if(one == null && two == null)
{
return true;
}

if(one == null || two == null || one.size() != two.size())
{
return false;
}

// to avoid messing the order of the lists we will use a copy
final List<ChipBadgeExtension<FilterCondition<T, ?>>> oneCopy = new ArrayList<>(one);
final List<ChipBadgeExtension<FilterCondition<T, ?>>> twoCopy = new ArrayList<>(two);

oneCopy.sort(Comparator.comparing(ChipBadge::getBadgeId));
twoCopy.sort(Comparator.comparing(ChipBadge::getBadgeId));
return one.equals(two);
return one.stream()
.map(ChipBadge::getBadgeId)
.collect(Collectors.toSet())
.equals(two.stream()
.map(ChipBadge::getBadgeId)
.collect(Collectors.toSet()));
}
}

0 comments on commit fe4f39b

Please sign in to comment.