| Modifier and Type | Class and Description |
|---|---|
static class |
IdGenerator.Builder |
| Modifier and Type | Method and Description |
|---|---|
static IdGenerator.Builder |
builder() |
String |
generateId(String text)
Generate an ID based on the provided text and previously generated IDs.
|
public static IdGenerator.Builder builder()
public String generateId(String text)
Generate an ID based on the provided text and previously generated IDs.
This method is not thread safe, concurrent calls can end up with non-unique identifiers.
Note that collision can occur in the case that
In that case, the three generated IDs will be:
Therefore if collisions are unacceptable you should ensure that
numbers are stripped from end of text.
text - Text that the identifier should be based on. Will be normalised, then used to generate the
identifier.text if this is the first instance that the text has been passed
to the method. Otherwise, text + "-" + X will be returned, where X is the number of times
that text has previously been passed in. If text is empty, the default
identifier given in the constructor will be used.Copyright © 2022. All rights reserved.