]> git.basschouten.com Git - openhab-addons.git/blob
e9bd52b20676b83e98c9043af792f5b805fdaa3c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.sensibo.internal;
14
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.Locale;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.sensibo.internal.handler.SensiboSkyHandler;
22 import org.openhab.core.thing.binding.ThingHandler;
23 import org.openhab.core.thing.binding.ThingHandlerService;
24 import org.openhab.core.thing.type.ChannelGroupType;
25 import org.openhab.core.thing.type.ChannelGroupTypeProvider;
26 import org.openhab.core.thing.type.ChannelGroupTypeUID;
27 import org.openhab.core.thing.type.ChannelType;
28 import org.openhab.core.thing.type.ChannelTypeProvider;
29 import org.openhab.core.thing.type.ChannelTypeUID;
30 import org.osgi.service.component.annotations.Component;
31 import org.osgi.service.component.annotations.ServiceScope;
32
33 /**
34  * Channel Type Provider that does a callback the SensiboSkyHandler that initiated it.
35  *
36  * @author Arne Seime - Initial contribution
37  */
38 @Component(scope = ServiceScope.PROTOTYPE, service = { CallbackChannelsTypeProvider.class, ChannelTypeProvider.class,
39         ChannelGroupTypeProvider.class })
40 @NonNullByDefault
41 public class CallbackChannelsTypeProvider
42         implements ChannelTypeProvider, ChannelGroupTypeProvider, ThingHandlerService {
43     private @NonNullByDefault({}) SensiboSkyHandler handler;
44
45     @Override
46     public Collection<ChannelType> getChannelTypes(@Nullable final Locale locale) {
47         return handler.getChannelTypes(locale);
48     }
49
50     @Override
51     public @Nullable ChannelType getChannelType(final ChannelTypeUID channelTypeUID, @Nullable final Locale locale) {
52         return handler.getChannelType(channelTypeUID, locale);
53     }
54
55     @Override
56     public @Nullable ChannelGroupType getChannelGroupType(final ChannelGroupTypeUID channelGroupTypeUID,
57             @Nullable final Locale locale) {
58         return null;
59     }
60
61     @Override
62     public Collection<ChannelGroupType> getChannelGroupTypes(@Nullable final Locale locale) {
63         return Collections.emptyList();
64     }
65
66     @Override
67     @Nullable
68     public ThingHandler getThingHandler() {
69         return handler;
70     }
71
72     @NonNullByDefault({})
73     @Override
74     public void setThingHandler(final ThingHandler handler) {
75         this.handler = (SensiboSkyHandler) handler;
76     }
77 }