]> git.basschouten.com Git - openhab-addons.git/blob
115a6ea126339d30359d4e12dbb7ee2a3e35238a
[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.hdpowerview.internal.builders;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.hdpowerview.internal.HDPowerViewBindingConstants;
21 import org.openhab.binding.hdpowerview.internal.HDPowerViewTranslationProvider;
22 import org.openhab.core.thing.Channel;
23 import org.openhab.core.thing.ChannelGroupUID;
24 import org.openhab.core.thing.type.ChannelTypeUID;
25
26 /**
27  * The {@link BaseChannelBuilder} class is super class for
28  * channel builders.
29  *
30  * @author Jacob Laursen - Initial contribution
31  */
32 @NonNullByDefault
33 public class BaseChannelBuilder {
34
35     protected final HDPowerViewTranslationProvider translationProvider;
36     protected final ChannelGroupUID channelGroupUid;
37     protected final ChannelTypeUID channelTypeUid;
38
39     @Nullable
40     protected List<Channel> channels;
41
42     protected BaseChannelBuilder(HDPowerViewTranslationProvider translationProvider, ChannelGroupUID channelGroupUid,
43             String channelTypeId) {
44         this.translationProvider = translationProvider;
45         this.channelGroupUid = channelGroupUid;
46         this.channelTypeUid = new ChannelTypeUID(HDPowerViewBindingConstants.BINDING_ID, channelTypeId);
47     }
48
49     protected List<Channel> getChannelList(int initialCapacity) {
50         List<Channel> channels = this.channels;
51         return channels != null ? channels : new ArrayList<>(initialCapacity);
52     }
53 }