]> git.basschouten.com Git - openhab-addons.git/blob
aa4437d6c5d0146a3e93ea84de3960ff9cfeb08b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.yamahareceiver.internal.state;
14
15 import java.util.ArrayList;
16 import java.util.List;
17 import java.util.Objects;
18
19 /**
20  * The preset state containing the channel names and currently selected channel
21  *
22  * @author David Graeff - Initial contribution
23  * @author Tomasz Maruszak - RX-V3900 compatibility improvements
24  */
25 public class PresetInfoState implements Invalidateable {
26     public static class Preset {
27         private final String name;
28         private final int value;
29
30         public Preset(String name, int value) {
31             this.name = name;
32             this.value = value;
33         }
34
35         public String getName() {
36             return name;
37         }
38
39         public int getValue() {
40             return value;
41         }
42
43         @Override
44         public boolean equals(Object o) {
45             if (this == o) {
46                 return true;
47             }
48             if (o == null || getClass() != o.getClass()) {
49                 return false;
50             }
51             Preset preset = (Preset) o;
52             return value == preset.value && Objects.equals(name, preset.name);
53         }
54
55         @Override
56         public int hashCode() {
57             return Objects.hash(name, value);
58         }
59     }
60
61     public int presetChannel = 0; // Used by NET_RADIO, RADIO, HD_RADIO, iPOD, USB, PC
62     public final List<Preset> presetChannelNames = new ArrayList<>();
63     public boolean presetChannelNamesChanged = false;
64
65     @Override
66     public void invalidate() {
67         presetChannel = 0;
68         presetChannelNames.clear();
69     }
70 }