本文整理汇总了Java中com.fasterxml.uuid.Generators.randomBasedGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java Generators.randomBasedGenerator方法的具体用法?Java Generators.randomBasedGenerator怎么用?Java Generators.randomBasedGenerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.uuid.Generators
的用法示例。
在下文中一共展示了Generators.randomBasedGenerator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureGeneratorInitialized
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
private static void ensureGeneratorInitialized() {
if (timeGenerator == null) {
synchronized (UUIDUtils.class) {
if (timeGenerator == null) {
timeGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
if (randomGenerator == null) {
synchronized (com.fasterxml.uuid.UUIDGenerator.class) {
if (randomGenerator == null) {
randomGenerator = Generators.randomBasedGenerator();
}
}
}
}
示例2: shortUuid
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
/**
* Generate short version random UUID
*
* @return UUID
*/
public static String shortUuid() {
RandomBasedGenerator generator = Generators.randomBasedGenerator();
UUID uuid = generator.generate();
// https://gist.github.com/LeeSanghoon/5811136
long l = ByteBuffer.wrap(uuid.toString().getBytes()).getLong();
return Long.toString(l, Character.MAX_RADIX);
}
示例3: UUIDRandomIDGenerator
import com.fasterxml.uuid.Generators; //导入方法依赖的package包/类
public UUIDRandomIDGenerator() {
generator = Generators.randomBasedGenerator();
}