Class UIDUtils


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

      • UIDUtils

        public UIDUtils()
    • Method Detail

      • encode

        public static String encode​(String value)
        Encodes a given string to an 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 an 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