Package com.peterphi.std.types
Class SimpleId
java.lang.Object
com.peterphi.std.types.Id
com.peterphi.std.types.SimpleId
- All Implemented Interfaces:
Serializable
,Comparable<Id>
A simple, untyped Id field; this is one step above having a String id
It is recommended that users extend Id themselves rather than using this type (as a SimpleId adds no discernable information about what the id is for)
It is recommended that users extend Id themselves rather than using this type (as a SimpleId adds no discernable information about what the id is for)
- See Also:
-
Field Summary
Fields inherited from class com.peterphi.std.types.Id
id, SANITY_CHECK
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
alphanumeric
(int length) Generates a random sequence of alphanumeric characters of lengthlength
using a new pseudorandom number generator (new Random()
)static final String
alphanumeric
(String prefix, int totalLength) Generates a random sequence of alphanumeric characters, prefixed byprefix
such that the total string is of lengthtotalLength
using a new pseudorandom number generator (new Random()
)static final String
alphanumeric
(Random random, int length) Generates a random sequence of alphanumeric characters of lengthlength
using the provided random number generatorstatic SimpleId
random()
Return an Id which uses 32 random alphanumeric characters as its value
-
Constructor Details
-
SimpleId
- Parameters:
id
-
-
SimpleId
-
-
Method Details
-
random
Return an Id which uses 32 random alphanumeric characters as its value- Returns:
-
alphanumeric
Generates a random sequence of alphanumeric characters of lengthlength
using a new pseudorandom number generator (new Random()
)- Parameters:
length
- the length of the string to generate (must be > 0)- Returns:
- a new random alphanumeric String of length
length
-
alphanumeric
Generates a random sequence of alphanumeric characters, prefixed byprefix
such that the total string is of lengthtotalLength
using a new pseudorandom number generator (new Random()
)- Parameters:
totalLength
- the length of the string to return (must be > the prefix length)- Returns:
- a String of length
length
-
alphanumeric
Generates a random sequence of alphanumeric characters of lengthlength
using the provided random number generator- Parameters:
random
- the random number generator to use (must not be null)length
- the length of the string to generate (must be > 0)- Returns:
- a new random alphanumeric String of length
length
-