Class GlobalIDFactory

java.lang.Object
com.helger.base.id.factory.GlobalIDFactory

@ThreadSafe public final class GlobalIDFactory extends Object
This class should not be static since it may have an impact if this class is used by different projects which have a separate IntID factory.
Author:
Philip Helger
  • Field Details

    • DEFAULT_PREFIX

      public static final String DEFAULT_PREFIX
      The default prefix to use for creating IDs
      See Also:
    • STRING_ID_MAX_LENGTH

      public static final int STRING_ID_MAX_LENGTH
      The maximum string length of IDs created by the String based ID factory. This length should at least fit a UUID v4 (36 chars)
      See Also:
  • Method Details

    • hasIntIDFactory

      public static boolean hasIntIDFactory()
      Returns:
      true if a non-persistent int ID factory is set, false otherwise.
    • getIntIDFactory

      public static @Nullable IIntIDFactory getIntIDFactory()
      Returns:
      The factory to create non-persistent int IDs. May be null.
    • setIntIDFactory

      public static @NonNull EChange setIntIDFactory(@Nullable IIntIDFactory aFactory)
      Set the non-persistent int ID factory.
      Parameters:
      aFactory - The factory to set. May be null.
      Returns:
      EChange.CHANGED if the factory was changed.
    • hasPersistentIntIDFactory

      public static boolean hasPersistentIntIDFactory()
      Returns:
      true if a persistent int ID factory is set, false otherwise.
    • getPersistentIntIDFactory

      public static @Nullable IIntIDFactory getPersistentIntIDFactory()
      Returns:
      The factory to create persistent int IDs. May be null.
    • setPersistentIntIDFactory

      public static @NonNull EChange setPersistentIntIDFactory(@Nullable IIntIDFactory aFactory)
      Set the persistent int ID factory.
      Parameters:
      aFactory - The factory to set. May be null.
      Returns:
      EChange.CHANGED if the factory was changed.
    • hasLongIDFactory

      public static boolean hasLongIDFactory()
      Returns:
      true if a non-persistent long ID factory is set, false otherwise.
    • getLongIDFactory

      public static @Nullable ILongIDFactory getLongIDFactory()
      Returns:
      The factory to create non-persistent long IDs. May be null.
    • setLongIDFactory

      public static @NonNull EChange setLongIDFactory(@Nullable ILongIDFactory aFactory)
      Set the non-persistent long ID factory.
      Parameters:
      aFactory - The factory to set. May be null.
      Returns:
      EChange.CHANGED if the factory was changed.
    • hasPersistentLongIDFactory

      public static boolean hasPersistentLongIDFactory()
      Returns:
      true if a persistent long ID factory is set, false otherwise.
    • getPersistentLongIDFactory

      public static @Nullable ILongIDFactory getPersistentLongIDFactory()
      Returns:
      The factory to create persistent long IDs. May be null.
    • setPersistentLongIDFactory

      public static @NonNull EChange setPersistentLongIDFactory(@Nullable ILongIDFactory aFactory)
      Set the persistent long ID factory.
      Parameters:
      aFactory - The factory to set. May be null.
      Returns:
      EChange.CHANGED if the factory was changed.
    • hasStringIDFactory

      public static boolean hasStringIDFactory()
      Returns:
      true if a non-persistent string ID factory is set, false otherwise.
    • getStringIDFactory

      public static @Nullable IStringIDFactory getStringIDFactory()
      Returns:
      The factory to create non-persistent string IDs. May be null.
    • setStringIDFactory

      public static @NonNull EChange setStringIDFactory(@Nullable IStringIDFactory aFactory)
      Set the non-persistent string ID factory.
      Parameters:
      aFactory - The factory to set. May be null.
      Returns:
      EChange.CHANGED if the factory was changed.
    • hasPersistentStringIDFactory

      public static boolean hasPersistentStringIDFactory()
      Returns:
      true if a persistent string ID factory is set, false otherwise.
    • getPersistentStringIDFactory

      public static @Nullable IStringIDFactory getPersistentStringIDFactory()
      Returns:
      The factory to create persistent string IDs. May be null.
    • setPersistentStringIDFactory

      public static @NonNull EChange setPersistentStringIDFactory(@Nullable IStringIDFactory aFactory)
      Set the persistent string ID factory.
      Parameters:
      aFactory - The factory to set. May be null.
      Returns:
      EChange.CHANGED if the factory was changed.
    • getNewIntID

      public static int getNewIntID()
      Returns:
      A new int ID
    • getNewPersistentIntID

      public static int getNewPersistentIntID()
      Returns:
      A new persistent int ID
    • getNewLongID

      public static long getNewLongID()
      Returns:
      A new long ID
    • getNewPersistentLongID

      public static long getNewPersistentLongID()
      Returns:
      A new persistent long ID
    • getNewStringID

      public static @NonNull String getNewStringID()
      Returns:
      A new String ID
    • getNewPersistentStringID

      public static @NonNull String getNewPersistentStringID()
      Returns:
      A new persistent String ID
    • getBulkNewIntIDs

      public static int[] getBulkNewIntIDs(@Nonnegative int nCount)
      Parameters:
      nCount - The number of IDs to retrieve. Must be > 0.
      Returns:
      An array of new int IDs
    • getBulkNewPersistentIntIDs

      public static int[] getBulkNewPersistentIntIDs(@Nonnegative int nCount)
      Parameters:
      nCount - The number of IDs to retrieve. Must be > 0.
      Returns:
      An array of new persistent int IDs
    • getBulkNewLongIDs

      public static long[] getBulkNewLongIDs(@Nonnegative int nCount)
      Parameters:
      nCount - The number of IDs to retrieve. Must be > 0.
      Returns:
      An array of new long IDs
    • getBulkNewPersistentLongIDs

      public static long[] getBulkNewPersistentLongIDs(@Nonnegative int nCount)
      Parameters:
      nCount - The number of IDs to retrieve. Must be > 0.
      Returns:
      An array of new persistent long IDs
    • getBulkNewStringIDs

      public static @NonNull String[] getBulkNewStringIDs(@Nonnegative int nCount)
      Parameters:
      nCount - The number of IDs to retrieve
      Returns:
      An array of new String IDs
    • getBulkNewPersistentStringIDs

      public static @NonNull String[] getBulkNewPersistentStringIDs(@Nonnegative int nCount)
      Parameters:
      nCount - The number of IDs to retrieve. Must be > 0.
      Returns:
      An array of new persistent String IDs