Skip to content

Commit

Permalink
Fixing immutable sets
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaremagico committed May 10, 2024
1 parent 931965d commit 8a11671
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public abstract class ElementConverter<F, T, R extends ConverterRequest<F>> implements IElementConverter<F, T, R> {

Expand All @@ -43,14 +44,14 @@ public List<T> convertAll(Collection<R> from) {
if (from == null) {
return new ArrayList<>();
}
return from.stream().map(this::convert).toList();
return from.stream().map(this::convert).collect(Collectors.toCollection(ArrayList::new));
}

@Override
public List<F> reverseAll(Collection<T> to) {
if (to == null) {
return new ArrayList<>();
}
return to.stream().map(this::reverse).toList();
return to.stream().map(this::reverse).collect(Collectors.toCollection(ArrayList::new));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,10 @@ public List<ScoreOfCompetitor> getCompetitorsGlobalScoreRanking(Collection<Parti
from == null || duel.getCreatedAt().isAfter(from)).toList();

final Set<Participant> participantsInFights = fights.stream().flatMap(fight ->
fight.getTeam1().getMembers().stream()).collect(Collectors.toSet());
participantsInFights.addAll(fights.stream().flatMap(fight -> fight.getTeam2().getMembers().stream()).collect(Collectors.toSet()));
competitors.retainAll(new HashSet<>(participantsInFights));
fight.getTeam1().getMembers().stream()).collect(Collectors.toCollection(HashSet::new));
participantsInFights.addAll(fights.stream().flatMap(fight -> fight.getTeam2().getMembers().stream())
.collect(Collectors.toCollection(HashSet::new)));
competitors.retainAll(participantsInFights);
for (final Participant competitor : competitors) {
scores.add(new ScoreOfCompetitor(competitor, fights, unties, false));
}
Expand Down

0 comments on commit 8a11671

Please sign in to comment.