Class IdGenerator

java.lang.Object
jadex.bpmn.model.io.IdGenerator

public class IdGenerator extends Object
A configurable Id generator.
  • Field Details

    • DEFAULT_ID_SIZE

      protected static final int DEFAULT_ID_SIZE
      The default ID size.
      See Also:
    • random

      protected Random random
      Random number generator.
    • idsize

      protected int idsize
      The selected id size.
    • encoder

      protected jadex.common.IResultCommand<String,byte[]> encoder
    • generatedIds

      protected Set<String> generatedIds
      Set of generated IDs to guarantee collision-free IDs.
  • Constructor Details

    • IdGenerator

      public IdGenerator()
      Creates a new ID generator.
    • IdGenerator

      public IdGenerator(int idsize)
      Creates a new ID generator.
      Parameters:
      idsize - Size of ID entropy in bytes, actual ID is slightly larger due to Base64 encoding.
    • IdGenerator

      public IdGenerator(boolean collisionfree)
      Creates a new ID generator.
      Parameters:
      collisionfree - If true, this will guarantee collision-free IDs. However, requires maintaining a set of used IDs, increasing memory consumption. This option is unnecessary for most use cases due to the extremely low probability of collisions at reasonable ID sizes.
    • IdGenerator

      public IdGenerator(int idsize, boolean collisionfree)
      Creates a new ID generator.
      Parameters:
      idsize - Size of ID entropy in bytes, actual ID is slightly larger due to Base64 encoding.
      collisionfree - If true, this will guarantee collision-free IDs. However, requires maintaining a set of used IDs, increasing memory consumption. This option is unnecessary for most use cases due to the extremely low probability of collisions at reasonable ID sizes.
  • Method Details

    • generateId

      public String generateId()
      Generates an ID.
      Returns:
      The ID.
    • addUsedId

      public void addUsedId(String id)
      Adds a used ID, only useful for collision-free mode.
      Parameters:
      id - The id.
    • removeUsedId

      public void removeUsedId(String id)
      Removes a used ID, only useful in collision-free mode.
      Parameters:
      id - The ID.
    • base64Mode

      public void base64Mode()
      Switches the ID generator to BASE64 mode.
    • base16Mode

      public void base16Mode()
      Switches the ID generator to BASE16 mode.
    • main

      public static void main(String[] args)