]> git.basschouten.com Git - openhab-addons.git/blob
8b86d37f15a3c374c2460ccbd8ca989491f1d73d
[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.sonos.internal;
14
15 import java.util.List;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.events.EventPublisher;
20 import org.openhab.core.thing.ChannelUID;
21 import org.openhab.core.thing.binding.BaseDynamicStateDescriptionProvider;
22 import org.openhab.core.thing.i18n.ChannelTypeI18nLocalizationService;
23 import org.openhab.core.thing.link.ItemChannelLinkRegistry;
24 import org.openhab.core.thing.type.DynamicStateDescriptionProvider;
25 import org.openhab.core.types.StateOption;
26 import org.osgi.service.component.annotations.Activate;
27 import org.osgi.service.component.annotations.Component;
28 import org.osgi.service.component.annotations.Reference;
29
30 /**
31  * Dynamic provider of state options while leaving other state description fields as original.
32  *
33  * @author Laurent Garnier - Initial contribution
34  */
35 @Component(service = { DynamicStateDescriptionProvider.class, SonosStateDescriptionOptionProvider.class })
36 @NonNullByDefault
37 public class SonosStateDescriptionOptionProvider extends BaseDynamicStateDescriptionProvider {
38
39     @Activate
40     public SonosStateDescriptionOptionProvider(final @Reference EventPublisher eventPublisher, //
41             final @Reference ItemChannelLinkRegistry itemChannelLinkRegistry, //
42             final @Reference ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService) {
43         this.eventPublisher = eventPublisher;
44         this.itemChannelLinkRegistry = itemChannelLinkRegistry;
45         this.channelTypeI18nLocalizationService = channelTypeI18nLocalizationService;
46     }
47
48     public @Nullable List<StateOption> getStateOptions(ChannelUID channelUID) {
49         return channelOptionsMap.get(channelUID);
50     }
51 }