public class NameManager extends Object
But, to ensure performance, duplicate checking will run MAX_CHECKING_ROUND
times at max. After MAX_CHECKING_ROUND times re-generation,
NameManager will always return a response, even there still exists a
duplicate name already. And, if so, the new name will replace the old one.
| Constructor and Description |
|---|
NameManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
MAX_LOOP_ROUND(long MAX_CHECKING_ROUND)
Set the round of duplicate checking.
|
static void |
release(String name)
Release the name under DEFAULT_NAMESPACE after using.
|
static void |
release(String namespace,
String name)
Release the name under namespace after using.
|
static void |
UNIQUE_NAME_LENGTH(int UNIQUE_NAME_LENGTH)
Set the length of random name.
|
static String |
uniqueName()
Generate a unique name under DEFAULT_NAMESPACE.
|
static String |
uniqueName(String namespace)
Generate a unique name under namespace
|
public static void UNIQUE_NAME_LENGTH(int UNIQUE_NAME_LENGTH)
To ensure no duplicate name existing, you can set the length to a big integer.
UNIQUE_NAME_LENGTH - the length of random namepublic static void MAX_LOOP_ROUND(long MAX_CHECKING_ROUND)
To ensure no duplicate name existing, you can set the round to a big integer. But too many rounds would go against performance.
MAX_CHECKING_ROUND - the number of checking roundpublic static String uniqueName()
public static String uniqueName(String namespace)
namespace - namespacepublic static void release(String name)
name - name to releaseCopyright © 2019. All rights reserved.