Class ChannelBuilder


  • @NonNullByDefault
    public class ChannelBuilder
    extends Object
    ChannelBuilder is responsible for creating Channels.
    Author:
    Dennis Nobel - Initial contribution, Alex Tugarev - Extended about default tags, Chris Jackson - Added properties and label/description
    • Method Detail

      • create

        public static ChannelBuilder create​(ChannelUID channelUID,
                                            @Nullable String acceptedItemType)
        Creates a channel builder for the given channel UID and item type.
        Parameters:
        channelUID - channel UID
        acceptedItemType - item type that is accepted by this channel
        Returns:
        channel builder
      • create

        public static ChannelBuilder create​(Channel channel)
        Creates a channel builder from the given channel.
        Parameters:
        channel - the channel to be changed
        Returns:
        channel builder
      • withType

        public ChannelBuilder withType​(@Nullable ChannelTypeUID channelTypeUID)
        Appends the channel type to the channel to build
        Parameters:
        channelTypeUID - channel type UID
        Returns:
        channel builder
      • withConfiguration

        public ChannelBuilder withConfiguration​(Configuration configuration)
        Appends a configuration to the channel to build.
        Parameters:
        configuration - configuration
        Returns:
        channel builder
      • withProperties

        public ChannelBuilder withProperties​(Map<String,​String> properties)
        Adds properties to the channel
        Parameters:
        properties - properties to add
        Returns:
        channel builder
      • withLabel

        public ChannelBuilder withLabel​(String label)
        Sets the channel label. This allows overriding of the default label set in the ChannelType
        Parameters:
        label - the channel label to override the label set in the ChannelType
        Returns:
        channel builder
      • withDescription

        public ChannelBuilder withDescription​(String description)
        Sets the channel label. This allows overriding of the default label set in the ChannelType
        Parameters:
        label - the channel label to override the label set in the ChannelType
        Returns:
        channel builder
      • withDefaultTags

        public ChannelBuilder withDefaultTags​(Set<String> defaultTags)
        Appends default tags to the channel to build.
        Parameters:
        defaultTags - default tags
        Returns:
        channel builder
      • withKind

        public ChannelBuilder withKind​(ChannelKind kind)
        Sets the kind of the channel.
        Parameters:
        kind - kind.
        Returns:
        channel builder
      • withAutoUpdatePolicy

        public ChannelBuilder withAutoUpdatePolicy​(@Nullable AutoUpdatePolicy policy)
        Sets the auto update policy. See AutoUpdatePolicy for details.
        Parameters:
        policy - the auto update policy to use
        Returns:
        channel builder
      • build

        public Channel build()
        Builds and returns the channel.
        Returns:
        channel