Class ThingBuilder
java.lang.Object
org.openhab.core.thing.binding.builder.ThingBuilder
- Direct Known Subclasses:
BridgeBuilder
This class allows the easy construction of a
Thing instance using the builder pattern.- Author:
- Dennis Nobel - Initial contribution, Kai Kreuzer - Refactoring to make BridgeBuilder a subclass, Andrew Fiddian-Green - Added semanticEquipmentTag
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThingBuilder(ThingTypeUID thingTypeUID, ThingUID thingUID) -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the thingstatic ThingBuilderCreate a new thingThingBuilderfor a copy of the given thingstatic ThingBuildercreate(ThingTypeUID thingTypeUID, String thingId) Create a newThingBuilderstatic ThingBuildercreate(ThingTypeUID thingTypeUID, ThingUID thingUID) Create a newThingBuilderprotected Thingpopulate(org.openhab.core.thing.internal.ThingImpl thing) withBridge(@Nullable ThingUID bridgeUID) Set the bridge for this thingwithChannel(Channel channel) Adds the given channel to the thingwithChannels(List<Channel> channels) Replaces all channels of this thing with the given channelswithChannels(Channel... channels) Replaces all channels of this thing with the given channelswithConfiguration(Configuration configuration) Set (or replace) the configuration of the thingSets thelabelfor the thingwithLocation(@Nullable String location) Set the location for this thingwithoutChannel(ChannelUID channelUID) Removes the channel with the given UID from the thingwithoutChannels(List<Channel> channels) Removes the given channels from the thingwithoutChannels(Channel... channels) Removes the given channels from the thingwithProperties(Map<String, String> properties) Set/replace the properties for this thingwithProperty(String key, String value) Set / replace a single property for this thingwithSemanticEquipmentTag(@Nullable String semanticEquipmentTag) Set the semantic (equipment) tag for this thingwithSemanticEquipmentTag(SemanticTag semanticEquipmentTag) Set the semantic (equipment) tag for this thing
-
Field Details
-
thingUID
-
thingTypeUID
-
-
Constructor Details
-
ThingBuilder
-
-
Method Details
-
create
Create a newThingBuilder- Parameters:
thingTypeUID- theThingTypeUIDof the new thingthingId- the id part of theThingUIDof the new thing- Returns:
- the created
ThingBuilder
-
create
Create a newThingBuilder- Parameters:
thingTypeUID- theThingTypeUIDof the new thingthingUID- theThingUIDof the new thing- Returns:
- the created
ThingBuilder
-
create
Create a new thingThingBuilderfor a copy of the given thing- Parameters:
thing- theThingto create this builder from- Returns:
- the created
ThingBuilder
-
build
Build the thing- Returns:
- the
Thing
-
withLabel
Sets thelabelfor the thing- Parameters:
label- a string containing the label- Returns:
- the
ThingBuilderitself
-
withChannel
Adds the given channel to the thing- Parameters:
channel- theChannel- Returns:
- the
ThingBuilderitself - Throws:
IllegalArgumentException- if a channel with the same UID is already present or theChannelUIDis not valid
-
withChannels
Replaces all channels of this thing with the given channels- Parameters:
channels- one or moreChannels- Returns:
- the
ThingBuilderitself - Throws:
IllegalArgumentException- if a channel with the same UID is already present or theChannelUIDis not valid
-
withChannels
Replaces all channels of this thing with the given channels- Parameters:
channels- aListofChannels- Returns:
- the
ThingBuilderitself - Throws:
IllegalArgumentException- if a channel with the same UID is already present or theChannelUIDis not valid
-
withoutChannel
Removes the channel with the given UID from the thing- Parameters:
channelUID- theChannelUIDof the channel- Returns:
- the
ThingBuilderitself
-
withoutChannels
Removes the given channels from the thing- Parameters:
channels- one or moreChannels- Returns:
- the
ThingBuilderitself
-
withoutChannels
Removes the given channels from the thing- Parameters:
channels- aListofChannels- Returns:
- the
ThingBuilderitself
-
withConfiguration
Set (or replace) the configuration of the thing- Parameters:
configuration- aConfigurationfor this thing- Returns:
- the
ThingBuilderitself
-
withBridge
Set the bridge for this thing- Parameters:
bridgeUID- theThingUIDof the bridge for the thing- Returns:
- the
ThingBuilderitself
-
withProperty
Set / replace a single property for this thing- Parameters:
key- the key / name of the propertyvalue- the value of the property- Returns:
- the
ThingBuilderitself
-
withProperties
Set/replace the properties for this thing- Parameters:
properties- aMap<String,containing the propertiesString> - Returns:
- the
ThingBuilderitself
-
withLocation
Set the location for this thing- Parameters:
location- a string wih the location of the thing- Returns:
- the
ThingBuilderitself
-
withSemanticEquipmentTag
Set the semantic (equipment) tag for this thing- Parameters:
semanticEquipmentTag- a string with semantic (equipment) tag for this thing- Returns:
- the
ThingBuilderitself
-
withSemanticEquipmentTag
Set the semantic (equipment) tag for this thing- Parameters:
semanticEquipmentTag- semantic (equipment) tag for this thing- Returns:
- the
ThingBuilderitself
-
populate
-