Package com.helger.base.id.factory
Class GlobalIDFactory
java.lang.Object
com.helger.base.id.factory.GlobalIDFactory
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default prefix to use for creating IDsstatic final intThe maximum string length of IDs created by the String based ID factory. -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]getBulkNewIntIDs(int nCount) static long[]getBulkNewLongIDs(int nCount) static int[]getBulkNewPersistentIntIDs(int nCount) static long[]getBulkNewPersistentLongIDs(int nCount) static @NonNull String[]getBulkNewPersistentStringIDs(int nCount) static @NonNull String[]getBulkNewStringIDs(int nCount) static @Nullable IIntIDFactorystatic @Nullable ILongIDFactorystatic intstatic longstatic intstatic longstatic @NonNull Stringstatic @NonNull Stringstatic @Nullable IIntIDFactorystatic @Nullable ILongIDFactorystatic @Nullable IStringIDFactorystatic @Nullable IStringIDFactorystatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic @NonNull EChangesetIntIDFactory(@Nullable IIntIDFactory aFactory) Set the non-persistent int ID factory.static @NonNull EChangesetLongIDFactory(@Nullable ILongIDFactory aFactory) Set the non-persistent long ID factory.static @NonNull EChangesetPersistentIntIDFactory(@Nullable IIntIDFactory aFactory) Set the persistent int ID factory.static @NonNull EChangesetPersistentLongIDFactory(@Nullable ILongIDFactory aFactory) Set the persistent long ID factory.static @NonNull EChangesetPersistentStringIDFactory(@Nullable IStringIDFactory aFactory) Set the persistent string ID factory.static @NonNull EChangesetStringIDFactory(@Nullable IStringIDFactory aFactory) Set the non-persistent string ID factory.
-
Field Details
-
DEFAULT_PREFIX
The default prefix to use for creating IDs- See Also:
-
STRING_ID_MAX_LENGTH
public static final int STRING_ID_MAX_LENGTHThe 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:
trueif a non-persistent int ID factory is set,falseotherwise.
-
getIntIDFactory
- Returns:
- The factory to create non-persistent int IDs. May be
null.
-
setIntIDFactory
Set the non-persistent int ID factory.- Parameters:
aFactory- The factory to set. May benull.- Returns:
EChange.CHANGEDif the factory was changed.
-
hasPersistentIntIDFactory
public static boolean hasPersistentIntIDFactory()- Returns:
trueif a persistent int ID factory is set,falseotherwise.
-
getPersistentIntIDFactory
- Returns:
- The factory to create persistent int IDs. May be
null.
-
setPersistentIntIDFactory
Set the persistent int ID factory.- Parameters:
aFactory- The factory to set. May benull.- Returns:
EChange.CHANGEDif the factory was changed.
-
hasLongIDFactory
public static boolean hasLongIDFactory()- Returns:
trueif a non-persistent long ID factory is set,falseotherwise.
-
getLongIDFactory
- Returns:
- The factory to create non-persistent long IDs. May be
null.
-
setLongIDFactory
Set the non-persistent long ID factory.- Parameters:
aFactory- The factory to set. May benull.- Returns:
EChange.CHANGEDif the factory was changed.
-
hasPersistentLongIDFactory
public static boolean hasPersistentLongIDFactory()- Returns:
trueif a persistent long ID factory is set,falseotherwise.
-
getPersistentLongIDFactory
- Returns:
- The factory to create persistent long IDs. May be
null.
-
setPersistentLongIDFactory
Set the persistent long ID factory.- Parameters:
aFactory- The factory to set. May benull.- Returns:
EChange.CHANGEDif the factory was changed.
-
hasStringIDFactory
public static boolean hasStringIDFactory()- Returns:
trueif a non-persistent string ID factory is set,falseotherwise.
-
getStringIDFactory
- Returns:
- The factory to create non-persistent string IDs. May be
null.
-
setStringIDFactory
Set the non-persistent string ID factory.- Parameters:
aFactory- The factory to set. May benull.- Returns:
EChange.CHANGEDif the factory was changed.
-
hasPersistentStringIDFactory
public static boolean hasPersistentStringIDFactory()- Returns:
trueif a persistent string ID factory is set,falseotherwise.
-
getPersistentStringIDFactory
- Returns:
- The factory to create persistent string IDs. May be
null.
-
setPersistentStringIDFactory
Set the persistent string ID factory.- Parameters:
aFactory- The factory to set. May benull.- Returns:
EChange.CHANGEDif 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
- Returns:
- A new String ID
-
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
- Parameters:
nCount- The number of IDs to retrieve- Returns:
- An array of new String IDs
-
getBulkNewPersistentStringIDs
- Parameters:
nCount- The number of IDs to retrieve. Must be > 0.- Returns:
- An array of new persistent String IDs
-