Class ThingHelper

java.lang.Object
org.openhab.core.thing.util.ThingHelper

@NonNullByDefault public class ThingHelper extends Object
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 Details

    • ThingHelper

      public ThingHelper()
  • Method Details

    • equals

      public static boolean equals(Thing a, Thing b)
      Indicates whether two Things are technical equal.
      Parameters:
      a - Thing object
      b - another Thing object
      Returns:
      true whether a and b are equal, otherwise false
    • addChannelsToThing

      public static void addChannelsToThing(Thing thing, Collection<Channel> channels)
    • ensureUniqueChannels

      public static void ensureUniqueChannels(Channel[] channels)
      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

      public static void ensureUniqueChannels(Collection<Channel> channels)
      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

      public static void ensureUniqueChannels(Collection<Channel> channels, Channel channel)
      Ensures that there are no duplicate channels in the collection plus the additional one (i.e. not using the same ChannelUID)
      Parameters:
      channels - the List of channels to check
      channel - an additional channel
      Throws:
      IllegalArgumentException - in case there are duplicate channels found
    • merge

      public static Thing merge(Thing thing, ThingDTO updatedContents)
      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 into
      updatedContents - a DTO which carries the updated content
      Returns:
      A Thing instance, which is the result of the merge