Skip to content

Commit

Permalink
[hue] eliminate scenes having the same name (openhab#15976)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
  • Loading branch information
andrewfg authored Nov 29, 2023
1 parent b80273a commit 73ec188
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -1200,8 +1202,8 @@ public synchronized boolean updateSceneContributors(List<Resource> allScenes) {
sceneResourceEntries.clear();

ResourceReference thisReference = getResourceReference();
List<Resource> scenes = allScenes.stream().filter(s -> thisReference.equals(s.getGroup()))
.collect(Collectors.toList());
Set<Resource> scenes = allScenes.stream().filter(s -> thisReference.equals(s.getGroup()))
.collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Resource::getName))));

if (!scenes.isEmpty()) {
sceneContributorsCache.putAll(scenes.stream().collect(Collectors.toMap(s -> s.getId(), s -> s)));
Expand Down

0 comments on commit 73ec188

Please sign in to comment.