Class ChannelBuilder
java.lang.Object
org.openhab.core.thing.binding.builder.ChannelBuilder
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 Summary
Modifier and TypeMethodDescriptionbuild()Builds and returns theChannel.static ChannelBuilderCreates aChannelBuilderfrom the givenChannel.static ChannelBuildercreate(ChannelUID channelUID) Creates aChannelBuilderfor the givenChannelUID.static ChannelBuildercreate(ChannelUID channelUID, @Nullable String acceptedItemType) Creates aChannelBuilderfor the givenChannelUIDand item type.withAcceptedItemType(@Nullable String acceptedItemType) Sets the accepted item type of theChannelto be build.withAutoUpdatePolicy(@Nullable AutoUpdatePolicy policy) Sets theAutoUpdatePolicyto theChannelto be build.withConfiguration(Configuration configuration) Appends aConfigurationto theChannelto be build.withDefaultTags(Set<String> defaultTags) Appends default tags to theChannelto be build.withDescription(String description) Sets the channel description.withKind(ChannelKind kind) Sets theChannelKindof theChannelto be build.Sets the channel label.withProperties(Map<String, String> properties) Adds properties to theChannel.withType(@Nullable ChannelTypeUID channelTypeUID)
-
Method Details
-
create
Creates aChannelBuilderfor the givenChannelUID.- Parameters:
channelUID- theChannelUID- Returns:
- channel builder
-
create
Creates aChannelBuilderfor the givenChannelUIDand item type.- Parameters:
channelUID- theChannelUIDacceptedItemType- item type that is accepted by this channel- Returns:
- channel builder
-
create
Creates aChannelBuilderfrom the givenChannel.- Parameters:
channel- the channel to be changed- Returns:
- channel builder
-
withType
- Parameters:
channelTypeUID- theChannelTypeUID- Returns:
- channel builder
-
withConfiguration
Appends aConfigurationto theChannelto be build.- Parameters:
configuration- theConfiguration- Returns:
- channel builder
-
withProperties
Adds properties to theChannel.- Parameters:
properties- properties to add- Returns:
- channel builder
-
withLabel
Sets the channel label. This allows overriding of the default label set in theChannelType.- Parameters:
label- the channel label to override the label set in theChannelType- Returns:
- channel builder
-
withDescription
Sets the channel description. This allows overriding of the default description set in theChannelType.- Parameters:
description- the channel label to override the description set in theChannelType- Returns:
- channel builder
-
withDefaultTags
Appends default tags to theChannelto be build.- Parameters:
defaultTags- default tags- Returns:
- channel builder
-
withKind
Sets theChannelKindof theChannelto be build.- Parameters:
kind- theChannelKind- Returns:
- channel builder
-
withAcceptedItemType
Sets the accepted item type of theChannelto be build. SeeCoreItemFactory.getSupportedItemTypes()for a list of available item types.- Parameters:
acceptedItemType- item type that is accepted by this channel- Returns:
- channel builder
-
withAutoUpdatePolicy
Sets theAutoUpdatePolicyto theChannelto be build.- Parameters:
policy- theAutoUpdatePolicyto be used- Returns:
- channel builder
-
build
Builds and returns theChannel.- Returns:
- the
Channel
-