Class UIDUtils

java.lang.Object
org.openhab.core.util.UIDUtils

@NonNullByDefault public class UIDUtils extends Object
Utilities for UIDs.
Author:
Markus Rathgeb - Initial contribution
  • Constructor Details

    • UIDUtils

      public UIDUtils()
  • Method Details

    • encode

      public static String encode(String value)
      Encodes a given string to a UID using only allowed characters.

      The generated UID can be given to the decode(String) function and it will result into the given value.

      Parameters:
      value - the string that should be encoded to a valid UID
      Returns:
      a string that if a valid UID (with respect to the allowed characters)
    • decode

      public static String decode(String value)
      Decodes a UID that has been generated by the encode(String) function.

      This function should only be used for UIDs generated by the encode(String) function. For every other UID the result is rather useless or could result into an IllegalArgumentException.

      Parameters:
      value - the UID to decode
      Returns:
      the decoded UID string
      Throws:
      IllegalArgumentException - if the given UID is not a valid encoded input