]> git.basschouten.com Git - openhab-addons.git/blob
b36699a61fa4c5256560291c98c7729e9ccdd097
[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.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.thing.ChannelUID;
20 import org.openhab.core.thing.binding.BaseDynamicStateDescriptionProvider;
21 import org.openhab.core.thing.i18n.ChannelTypeI18nLocalizationService;
22 import org.openhab.core.thing.type.DynamicStateDescriptionProvider;
23 import org.openhab.core.types.StateOption;
24 import org.osgi.service.component.annotations.Component;
25 import org.osgi.service.component.annotations.Reference;
26
27 /**
28  * Dynamic provider of state options while leaving other state description fields as original.
29  *
30  * @author Laurent Garnier - Initial contribution
31  */
32 @Component(service = { DynamicStateDescriptionProvider.class, SonosStateDescriptionOptionProvider.class })
33 @NonNullByDefault
34 public class SonosStateDescriptionOptionProvider extends BaseDynamicStateDescriptionProvider {
35
36     public @Nullable List<StateOption> getStateOptions(ChannelUID channelUID) {
37         return channelOptionsMap.get(channelUID);
38     }
39
40     @Reference
41     protected void setChannelTypeI18nLocalizationService(
42             final ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService) {
43         this.channelTypeI18nLocalizationService = channelTypeI18nLocalizationService;
44     }
45
46     protected void unsetChannelTypeI18nLocalizationService(
47             final ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService) {
48         this.channelTypeI18nLocalizationService = null;
49     }
50 }