]> git.basschouten.com Git - openhab-addons.git/blob
d2951f7001b56086d9cfdb5228cbf47c86c6b06c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.atlona.internal.pro3;
14
15 import java.util.Collections;
16 import java.util.HashSet;
17 import java.util.Set;
18
19 import org.openhab.binding.atlona.internal.handler.AtlonaCapabilities;
20
21 /**
22  * The capabilities class for the Atlona PRO3 line. Each PRO3 model differs in the number of (output) ports that can be
23  * powered, the number of audio ports there are and which (output) ports are HDMI ports.
24  *
25  * @author Tim Roberts - Initial contribution
26  */
27 public class AtlonaPro3Capabilities extends AtlonaCapabilities {
28
29     /**
30      * Number of power ports
31      */
32     private final int nbrPowerPorts;
33
34     /**
35      * Number of audio ports
36      */
37     private final int nbrAudioPorts;
38
39     /**
40      * The set of output ports that are HDMI ports
41      */
42     private final Set<Integer> hdmiPorts;
43
44     /**
45      * Constructs the capabilities from the parms
46      *
47      * @param nbrPowerPorts a greater than 0 number of power ports
48      * @param nbrAudioPorts a greater than 0 number of audio ports
49      * @param hdmiPorts a non-null, non-empty set of hdmi ports
50      */
51     public AtlonaPro3Capabilities(int nbrPowerPorts, int nbrAudioPorts, Set<Integer> hdmiPorts) {
52         super();
53
54         if (nbrPowerPorts < 1) {
55             throw new IllegalArgumentException("nbrPowerPorts must be greater than 0");
56         }
57
58         if (nbrAudioPorts < 1) {
59             throw new IllegalArgumentException("nbrAudioPorts must be greater than 0");
60         }
61
62         if (hdmiPorts == null) {
63             throw new IllegalArgumentException("hdmiPorts cannot be null");
64         }
65
66         if (hdmiPorts.isEmpty()) {
67             throw new IllegalArgumentException("hdmiPorts cannot be empty");
68         }
69
70         this.nbrPowerPorts = nbrPowerPorts;
71         this.nbrAudioPorts = nbrAudioPorts;
72         this.hdmiPorts = Collections.unmodifiableSet(new HashSet<>(hdmiPorts));
73     }
74
75     /**
76      * Returns the number of power ports
77      *
78      * @return a greater than 0 number of power ports
79      */
80     int getNbrPowerPorts() {
81         return nbrPowerPorts;
82     }
83
84     /**
85      * Returns the number of audio ports
86      *
87      * @return a greater than 0 number of audio ports
88      */
89     int getNbrAudioPorts() {
90         return nbrAudioPorts;
91     }
92
93     /**
94      * Returns the set of hdmi ports
95      *
96      * @return a non-null, non-empty immutable set of hdmi ports
97      */
98     Set<Integer> getHdmiPorts() {
99         return hdmiPorts;
100     }
101 }