]> git.basschouten.com Git - openhab-addons.git/blob
9d6545a6b2a0527ad79a53f08922a76044e1ceef
[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.knx.internal.channel;
14
15 import static java.util.stream.Collectors.toList;
16
17 import java.util.List;
18 import java.util.stream.Stream;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22
23 /**
24  * Data structure representing the content of a channel's group address configuration.
25  *
26  * @author Simon Kaufmann - initial contribution and API.
27  *
28  */
29 @NonNullByDefault
30 public class ChannelConfiguration {
31
32     private final @Nullable String dpt;
33     private final GroupAddressConfiguration mainGA;
34     private final List<GroupAddressConfiguration> listenGAs;
35
36     public ChannelConfiguration(@Nullable String dpt, GroupAddressConfiguration mainGA,
37             List<GroupAddressConfiguration> listenGAs) {
38         this.dpt = dpt;
39         this.mainGA = mainGA;
40         this.listenGAs = listenGAs;
41     }
42
43     public @Nullable String getDPT() {
44         return dpt;
45     }
46
47     public GroupAddressConfiguration getMainGA() {
48         return mainGA;
49     }
50
51     public List<GroupAddressConfiguration> getListenGAs() {
52         return Stream.concat(Stream.of(mainGA), listenGAs.stream()).collect(toList());
53     }
54
55     public List<GroupAddressConfiguration> getReadGAs() {
56         return getListenGAs().stream().filter(ga -> ga.isRead()).collect(toList());
57     }
58 }