Class DiscoveryResultBuilder

java.lang.Object
org.openhab.core.config.discovery.DiscoveryResultBuilder

@NonNullByDefault public class DiscoveryResultBuilder extends Object
The DiscoveryResultBuilder helps creating a DiscoveryResult through the builder pattern.
Author:
Kai Kreuzer - Initial contribution, Andre Fuechsel - added support for time to live, Thomas Höfer - Added representation
See Also:
  • Method Details

    • create

      public static DiscoveryResultBuilder create(ThingUID thingUID)
      Creates a new builder for a given thing UID.
      Parameters:
      thingUID - the thing UID for which the builder should be created-
      Returns:
      a new instance of a DiscoveryResultBuilder
    • withThingType

      public DiscoveryResultBuilder withThingType(@Nullable ThingTypeUID thingTypeUID)
      Explicitly sets the thing type.
      Parameters:
      thingTypeUID - the ThingTypeUID
      Returns:
      the updated builder
    • withProperties

      public DiscoveryResultBuilder withProperties(@Nullable Map<String,Object> properties)
      Adds properties to the desired result.
      Parameters:
      properties - of the desired result
      Returns:
      the updated builder
    • withProperty

      public DiscoveryResultBuilder withProperty(String key, Object value)
      Adds a property to the desired result.
      Parameters:
      key - property of the desired result
      Returns:
      the updated builder
    • withRepresentationProperty

      public DiscoveryResultBuilder withRepresentationProperty(@Nullable String representationProperty)
      Sets the representation Property of the desired result.
      Parameters:
      representationProperty - the representation property of the desired result
      Returns:
      the updated builder
    • withBridge

      public DiscoveryResultBuilder withBridge(@Nullable ThingUID bridgeUID)
      Sets the bridgeUID of the desired result.
      Parameters:
      bridgeUID - of the desired result
      Returns:
      the updated builder
    • withLabel

      public DiscoveryResultBuilder withLabel(@Nullable String label)
      Sets the label of the desired result.
      Parameters:
      label - of the desired result
      Returns:
      the updated builder
    • withTTL

      public DiscoveryResultBuilder withTTL(long ttl)
      Sets the time to live for the result in seconds.
      Parameters:
      ttl - time to live in seconds
      Returns:
      the updated builder
    • build

      public DiscoveryResult build()
      Builds a result with the settings of this builder.
      Returns:
      the desired result