Package org.openhab.core.thing.util
Class ThingHelper
java.lang.Object
org.openhab.core.thing.util.ThingHelper
ThingHelper
provides a utility method to create and bind items.- Author:
- Oliver Libutzki - Initial contribution, Andre Fuechsel - graceful creation of items and links, Benedikt Niehues - Fix ESH Bug 450236 https://bugs.eclipse.org/bugs/show_bug.cgi?id=450236 - Considering ThingTypeDescription, Dennis Nobel - Removed createAndBindItems method, Kai Kreuzer - Added merge method
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addChannelsToThing
(Thing thing, Collection<Channel> channels) static void
ensureUniqueChannels
(Collection<Channel> channels) Ensures that there are no duplicate channels in the collection (i.e.static void
ensureUniqueChannels
(Collection<Channel> channels, Channel channel) Ensures that there are no duplicate channels in the collection plus the additional one (i.e.static void
ensureUniqueChannels
(Channel[] channels) Ensures that there are no duplicate channels in the array (i.e.static boolean
Indicates whether twoThing
s are technical equal.static Thing
Merges the content of a ThingDTO with an existing Thing.
-
Constructor Details
-
ThingHelper
public ThingHelper()
-
-
Method Details
-
equals
Indicates whether twoThing
s are technical equal.- Parameters:
a
- Thing objectb
- another Thing object- Returns:
- true whether a and b are equal, otherwise false
-
addChannelsToThing
-
ensureUniqueChannels
Ensures that there are no duplicate channels in the array (i.e. not using the same ChannelUID)- Parameters:
channels
- the channels to check- Throws:
IllegalArgumentException
- in case there are duplicate channels found
-
ensureUniqueChannels
Ensures that there are no duplicate channels in the collection (i.e. not using the same ChannelUID)- Parameters:
channels
- the channels to check- Throws:
IllegalArgumentException
- in case there are duplicate channels found
-
ensureUniqueChannels
Ensures that there are no duplicate channels in the collection plus the additional one (i.e. not using the same ChannelUID)- Parameters:
channels
- theList
of channels to checkchannel
- an additional channel- Throws:
IllegalArgumentException
- in case there are duplicate channels found
-
merge
Merges the content of a ThingDTO with an existing Thing. Where ever the DTO has null values, the content of the original Thing is kept. Where ever the DTO has non-null values, these are used. In consequence, care must be taken when the content of a list (like configuration, properties or channels) is to be updated - the DTO must contain the full list, otherwise entries will be deleted.- Parameters:
thing
- the Thing instance to merge the new content intoupdatedContents
- a DTO which carries the updated content- Returns:
- A Thing instance, which is the result of the merge
-