本文整理汇总了Java中java.util.UUID.toString方法的典型用法代码示例。如果您正苦于以下问题:Java UUID.toString方法的具体用法?Java UUID.toString怎么用?Java UUID.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.UUID
的用法示例。
在下文中一共展示了UUID.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCharacter
import java.util.UUID; //导入方法依赖的package包/类
public GameCharacter createCharacter(UUID owner, String characterName) throws UserNotFoundException, CharacterConflictException {
validateCharacterName(characterName);
// we only use lower-case character name
characterName = characterName.toLowerCase();
if (!userRepo.existsById(owner))
throw new UserNotFoundException(owner.toString());
if (characterRepo.existsByName(characterName))
throw new CharacterConflictException(characterName);
GameCharacter character = new GameCharacter();
character.setUuid(UUID.randomUUID());
character.setName(characterName);
character.setOwnerId(owner);
character.setModel(TextureModel.STEVE);
character.setTextures(new LinkedHashMap<>());
character.setCreateTime(System.currentTimeMillis());
character = characterRepo.save(character);
LOGGER.info("Character {} created with name {} and owner {}", character.getUuid(), character.getName(), character.getOwnerId());
eventPublisher.publishEvent(new CharacterCreationEvent(this, character.getUuid()));
return characterRepo.findById(character.getUuid()).get();
}
示例2: getUUID
import java.util.UUID; //导入方法依赖的package包/类
/**
* 获取设备唯一标识
*
* @param context
* @return
*/
public static String getUUID(Context context) {
final TelephonyManager tm = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
final String tmDevice, tmSerial, tmPhone, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String uniqueId = deviceUuid.toString();
if (BuildConfig.DEBUG)
Log.d(TAG, "uuid=" + uniqueId);
return uniqueId;
}
示例3: startCreditApplicationProcess
import java.util.UUID; //导入方法依赖的package包/类
@PostMapping("/")
public RedirectView startCreditApplicationProcess() {
//Create Credit Application Number
UUID creditApplicationNumber = UUID.randomUUID();
Date applicationTime = new Date();
LOGGER.info("Created a new Credit Application Number: " + creditApplicationNumber.toString());
// We are saving the initial status
CreditApplicationStatus status = new CreditApplicationStatus(creditApplicationNumber.toString(), applicationTime);
repository.save(status);
LOGGER.info("Saved " + status.toString());
// We are sending a CreditApplicationNumberGeneratedEvent
CreditApplicationNumberGeneratedEvent event = new CreditApplicationNumberGeneratedEvent();
event.setApplicationNumber(creditApplicationNumber.toString());
event.setCreationTime(applicationTime);
applicationProcessChannels.creditApplicationNumberGeneratedOut()
.send(MessageBuilder.withPayload(event).build());
LOGGER.info("Sent " + event.toString());
return new RedirectView(nextProcessStepUrl + creditApplicationNumber.toString());
}
示例4: addItems
import java.util.UUID; //导入方法依赖的package包/类
@Test
public void addItems() {
UUID bid = UUID.randomUUID();
UUID orangeId = UUID.randomUUID();
UUID bananaId = UUID.randomUUID();
BasketCommand.AddItem cmd1 = new BasketCommand.AddItem(orangeId, 3);
BasketCommand.AddItem cmd2 = new BasketCommand.AddItem(bananaId, 1);
BasketCommand.GetBasket cmd3 = BasketCommand.GetBasket.INSTANCE;
PersistentEntityTestDriver<BasketCommand, PEBasketEvent, BasketState> driver =
new PersistentEntityTestDriver<>(system, new BasketEntity(), bid.toString());
// add some oranges
Outcome<PEBasketEvent, BasketState> outcome1 = driver.run(cmd1);
assertEquals(Done.getInstance(), outcome1.getReplies().get(0));
assertEquals(Collections.emptyList(), outcome1.issues());
// and then add some bananas. Finally get the basket.
Outcome<PEBasketEvent, BasketState> outcome3 = driver.run(cmd2, cmd3);
PSequence<DomainBasketItem> items = TreePVector.<DomainBasketItem>empty()
.plus(new DomainBasketItem(orangeId, 3))
.plus(new DomainBasketItem(bananaId, 1));
BasketState expected = new BasketState(items, false);
assertEquals(expected, outcome3.getReplies().get(1));
assertEquals(Collections.emptyList(), outcome1.issues());
}
示例5: testReporter
import java.util.UUID; //导入方法依赖的package包/类
@Test
public void testReporter() throws Exception {
UUID uuid = UUID.randomUUID();
String metricName = "ApptuitReporterTest.testReporter." + uuid.toString();
int expectedCount=2;
AtomicBoolean foundMetric = new AtomicBoolean(false);
AtomicInteger lastSeenCount = new AtomicInteger(-1);
PutListener listener = dataPoints -> {
dataPoints.forEach(dataPoint -> {
if (!metricName.equals(dataPoint.getMetric()))
return;
int i = dataPoint.getValue().intValue();
lastSeenCount.set(i);
if (i != 2)
return;
foundMetric.set(true);
});
};
putClient.addPutListener(listener);
Counter counter = registry.counter(metricName);
counter.inc();
counter.inc();
await().atMost(period*3, TimeUnit.SECONDS).untilTrue(foundMetric);
putClient.removePutListener(listener);
assertEquals(expectedCount, lastSeenCount.intValue());
}
示例6: getDeviceUUID
import java.util.UUID; //导入方法依赖的package包/类
/**
* 获取设备序列号
*
* @return Str
*/
public static String getDeviceUUID() {
final TelephonyManager tm = (TelephonyManager) App.getDefault().getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(App.getDefault().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String uniqueId = deviceUuid.toString();
return uniqueId;
}
示例7: Players
import java.util.UUID; //导入方法依赖的package包/类
/**
* @param uniqueId
* Constructor - initializes the state variables
*
*/
public Players(final UUID uniqueId) {
this.uniqueId = uniqueId.toString();
this.homeLocations = new HashMap<>();
this.playerName = "";
this.resetsLeft = Settings.resetLimit;
this.locale = "";
this.useControlPanel = Settings.useControlPanel;
this.kickedList = new HashMap<>();
this.playerName = Bukkit.getServer().getOfflinePlayer(uniqueId).getName();
}
示例8: uuidToString
import java.util.UUID; //导入方法依赖的package包/类
public static String uuidToString(UUID uuid) {
String longUUID = uuid.toString();
Pattern pattern = Pattern.compile("0000(.{4})-0000-1000-8000-00805f9b34fb", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(longUUID);
if (matcher.matches()) {
// 16 bit UUID
return matcher.group(1);
} else {
return longUUID;
}
}
示例9: toResponse
import java.util.UUID; //导入方法依赖的package包/类
@Override
@Produces("text/html")
public Response toResponse(Throwable e) {
UUID errorId = UUID.randomUUID();
LOG.error("Internal server error " + errorId.toString(), e);
String errorString = "An error occurred while processing your request. Please contact the system administrator and provide the following error log ID " + errorId.toString();
return Response.serverError().entity(new Gson().toJson(errorString)).build();
}
示例10: generateGuid
import java.util.UUID; //导入方法依赖的package包/类
/**
* Generates a GUID using a seed. This will generate the same GUID usign the same seed.
* @param seed The seed to use for generating the GUID
* @return A string representation of the GUID
*/
public static String generateGuid(String seed) {
UUID uuid;
try {
uuid = UUID.nameUUIDFromBytes(seed.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(String.format("UnsupportedEncodingException: %f", e.getMessage()));
}
return uuid.toString();
}
示例11: adaptFromJson
import java.util.UUID; //导入方法依赖的package包/类
@Override
public String adaptFromJson(final UUID uuid) throws Exception {
return uuid.toString();
}
示例12: toString
import java.util.UUID; //导入方法依赖的package包/类
public String toString(UUID value)
{
return value == null ? "" : value.toString();
}
示例13: setSuite
import java.util.UUID; //导入方法依赖的package包/类
protected void setSuite(UUID id) {
String serializedSuite = id.toString();
serialized.addProperty("suite", serializedSuite);
}
示例14: getAccountByPlayer
import java.util.UUID; //导入方法依赖的package包/类
private UniqueAccount getAccountByPlayer(Player player)
{
UUID uniqueId = player.getUniqueId();
String message = "Unsupported account for uuid: " + uniqueId.toString();
return economyService.getOrCreateAccount(uniqueId).orElseThrow(() -> new IllegalArgumentException(message));
}
示例15: generateV1Uuid
import java.util.UUID; //导入方法依赖的package包/类
public static String generateV1Uuid(){
EthernetAddress addr = EthernetAddress.fromInterface();
TimeBasedGenerator uuidGenerator = Generators.timeBasedGenerator(addr);
UUID uuid = uuidGenerator.generate();
return uuid.toString();
}