Class BaseDynamicStateDescriptionProvider

    • Constructor Detail

      • BaseDynamicStateDescriptionProvider

        public BaseDynamicStateDescriptionProvider()
    • Method Detail

      • setStatePattern

        public void setStatePattern​(ChannelUID channelUID,
                                    String pattern)
        For a given ChannelUID, set a pattern that should be used for the channel, instead of the one defined statically in the ChannelType.
        Parameters:
        channelUID - the ChannelUID of the channel
        pattern - a pattern
      • getStateDescription

        public @Nullable StateDescription getStateDescription​(Channel channel,
                                                              @Nullable StateDescription original,
                                                              @Nullable Locale locale)
        Description copied from interface: DynamicStateDescriptionProvider
        For a given Channel, return a StateDescription that should be used for the channel, instead of the one defined statically in the ChannelType. For a particular channel, there should be only one provider of the dynamic state description. When more than one description is provided for the same channel (by different providers), only one will be used, from the provider that registered first. If the given channel will not be managed by the provider null should be returned. You never must return the original state description in such case.
        Specified by:
        getStateDescription in interface DynamicStateDescriptionProvider
        Parameters:
        channel - channel
        original - original state description retrieved from the channel type this is the description to be replaced by the provided one
        locale - locale (can be null)
        Returns:
        state description or null if none provided
      • localizeStatePattern

        protected @Nullable String localizeStatePattern​(String pattern,
                                                        Channel channel,
                                                        @Nullable Locale locale)
        Localizes a pattern that should be used for the channel.
        Parameters:
        pattern - a pattern
        channel - the channel
        locale - a locale
        Returns:
        the localized pattern