2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.monopriceaudio.internal.communication;
15 import java.util.Arrays;
16 import java.util.List;
17 import java.util.stream.Collectors;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.monopriceaudio.internal.MonopriceAudioException;
23 * Represents the different internal zone IDs of the Monoprice Whole House Amplifier
25 * @author Michael Lobstein - Initial contribution
28 public enum MonopriceAudioZone {
50 private final String zoneId;
52 // make a list of all valid zone names
53 public static final List<String> VALID_ZONES = Arrays.stream(values()).filter(z -> z != ALL)
54 .map(MonopriceAudioZone::name).collect(Collectors.toList());
56 // make a list of all valid zone ids
57 public static final List<String> VALID_ZONE_IDS = Arrays.stream(values()).filter(z -> z != ALL)
58 .map(MonopriceAudioZone::getZoneId).collect(Collectors.toList());
60 public static MonopriceAudioZone fromZoneId(String zoneId) throws MonopriceAudioException {
61 return Arrays.stream(values()).filter(z -> z.zoneId.equalsIgnoreCase(zoneId)).findFirst()
62 .orElseThrow(() -> new MonopriceAudioException("Invalid zoneId specified: " + zoneId));
65 MonopriceAudioZone(String zoneId) {
74 public String getZoneId() {