Class FirmwareBuilder

java.lang.Object
org.openhab.core.thing.binding.firmware.FirmwareBuilder

@NonNullByDefault public final class FirmwareBuilder extends Object
The builder to create a Firmware.
Author:
Thomas Höfer - Initial contribution, Dimitar Ivanov - Extracted as separate class for Firmware, introduced firmware restriction function
  • Method Details

    • create

      public static FirmwareBuilder create(ThingTypeUID thingTypeUID, String firmwareVersion)
    • withVendor

      public FirmwareBuilder withVendor(@Nullable String vendor)
      Adds the vendor to the builder.
      Parameters:
      vendor - the vendor to be added to the builder (can be null)
      Returns:
      the updated builder
    • withModel

      public FirmwareBuilder withModel(@Nullable String model)
      Adds the model to the builder.
      Parameters:
      model - the model to be added to the builder (can be null)
      Returns:
      the updated builder
    • withModelRestricted

      public FirmwareBuilder withModelRestricted(boolean modelRestricted)
      Sets the modelRestricted flag in the builder.
      Parameters:
      modelRestricted - the modelRestricted flag to be added to the builder
      Returns:
      the updated builder
    • withDescription

      public FirmwareBuilder withDescription(@Nullable String description)
      Adds the description to the builder.
      Parameters:
      description - the description to be added to the builder (can be null)
      Returns:
      the updated builder
    • withPrerequisiteVersion

      public FirmwareBuilder withPrerequisiteVersion(@Nullable String prerequisiteVersion)
      Adds the prerequisite version to the builder.
      Parameters:
      prerequisiteVersion - the prerequisite version to be added to the builder (can be null)
      Returns:
      the updated builder
    • withChangelog

      public FirmwareBuilder withChangelog(@Nullable String changelog)
      Adds the changelog to the builder.
      Parameters:
      changelog - the changelog to be added to the builder (can be null)
      Returns:
      the updated builder
    • withOnlineChangelog

      public FirmwareBuilder withOnlineChangelog(@Nullable URL onlineChangelog)
      Adds the online changelog to the builder.
      Parameters:
      onlineChangelog - the online changelog to be added to the builder (can be null)
      Returns:
      the updated builder
    • withInputStream

      public FirmwareBuilder withInputStream(@Nullable InputStream inputStream)
      Adds the input stream for the binary content to the builder.
      Parameters:
      inputStream - the input stream for the binary content to be added to the builder (can be null)
      Returns:
      the updated builder
    • withProperties

      public FirmwareBuilder withProperties(Map<String,String> properties)
      Adds the properties to the builder.
      Parameters:
      properties - the properties to be added to the builder (not null)
      Returns:
      the updated builder
      Throws:
      IllegalArgumentException - if the given properties are null
    • withMd5Hash

      public FirmwareBuilder withMd5Hash(@Nullable String md5Hash)
      Adds the given md5 hash value to the builder.
      Parameters:
      md5Hash - the md5 hash value to be added to the builder (can be null)
      Returns:
      the updated builder
    • withFirmwareRestriction

      public FirmwareBuilder withFirmwareRestriction(FirmwareRestriction firmwareRestriction)
      An additional restriction can be applied on the firmware by providing a FirmwareRestriction function.
      Parameters:
      firmwareRestriction - a FirmwareRestriction for applying an additional restriction function on the firmware (not null)
      Returns:
      the updated builder
      Throws:
      IllegalArgumentException - if the given function is null
    • build

      public Firmware build()
      Builds the firmware.
      Returns:
      the firmware instance based on this builder
      Throws:
      IllegalArgumentException - when the model restricted property (withModelRestricted(boolean)) is set to true, but the model (withModel(String)) is not set