Skip to content

Commit

Permalink
fix errors after lastnpe update
Browse files Browse the repository at this point in the history
  • Loading branch information
mlobstein committed Jul 15, 2024
1 parent 747da62 commit f797638
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package org.openhab.binding.monopriceaudio.internal.communication;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -216,7 +217,7 @@ private static MonopriceAudioZoneDTO getMonopriceZoneData(String newZoneData) {
private final int numSources;
private final boolean padNumbers;
private final List<String> zoneIds;
private Map<String, String> zoneIdMap = new HashMap<>();
private final Map<String, String> zoneIdMap;

private static final String ON_STR = "1";
private static final String OFF_STR = "0";
Expand Down Expand Up @@ -258,21 +259,25 @@ private static MonopriceAudioZoneDTO getMonopriceZoneData(String newZoneData) {
this.zoneIds = zoneIds;

// Build a map between the amp's physical zone IDs and the thing's logical zone names
final Map<String, String> zoneIdMap = new HashMap<>();
IntStream.range(0, zoneIds.size()).forEach(i -> zoneIdMap.put(zoneIds.get(i), "zone" + (i + 1)));
this.zoneIdMap = Collections.unmodifiableMap(zoneIdMap);
}

public abstract MonopriceAudioZoneDTO getZoneData(String newZoneData);

public abstract List<StateOption> getSourceLabels(MonopriceAudioThingConfiguration config);

public String getZoneIdFromZoneName(String zoneName) {
return zoneIdMap.entrySet().stream().filter(entry -> zoneName.equals(entry.getValue())).map(Map.Entry::getKey)
.findFirst().orElse("");
final String zoneId = zoneIdMap.entrySet().stream().filter(entry -> zoneName.equals(entry.getValue()))
.map(Map.Entry::getKey).findFirst().orElse("");
return zoneId != null ? zoneId : "";
}

public String getZoneName(String zoneId) {
return zoneIdMap.entrySet().stream().filter(entry -> zoneId.equals(entry.getKey())).map(Map.Entry::getValue)
.findFirst().orElse("");
final String zoneName = zoneIdMap.entrySet().stream().filter(entry -> zoneId.equals(entry.getKey()))
.map(Map.Entry::getValue).findFirst().orElse("");
return zoneName != null ? zoneName : "";
}

public String getCmdPrefix() {
Expand Down

0 comments on commit f797638

Please sign in to comment.