当前位置: 首页>>代码示例>>Java>>正文


Java UUID.toString方法代码示例

本文整理汇总了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();
}
 
开发者ID:yushijinhun,项目名称:akir,代码行数:27,代码来源:CharacterService.java

示例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;
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:22,代码来源:AppUtils.java

示例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());
}
 
开发者ID:mploed,项目名称:event-driven-spring-boot,代码行数:23,代码来源:ApplicationProcessController.java

示例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());

}
 
开发者ID:ignasi35,项目名称:lagom-java-workshop,代码行数:32,代码来源:BasketEntityTest.java

示例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());
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:33,代码来源:ApptuitReporterTest.java

示例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;

}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:17,代码来源:CommonUtil.java

示例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();
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:16,代码来源:Players.java

示例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;
	}
}
 
开发者ID:lenglengiOS,项目名称:react-native-blue-manager,代码行数:12,代码来源:UUIDHelper.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:12,代码来源:DefaultExceptionMapper.java

示例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();
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:15,代码来源:Utils.java

示例11: adaptFromJson

import java.util.UUID; //导入方法依赖的package包/类
@Override
public String adaptFromJson(final UUID uuid) throws Exception {
    return uuid.toString();
}
 
开发者ID:sdaschner,项目名称:scalable-coffee-shop,代码行数:5,代码来源:UUIDAdapter.java

示例12: toString

import java.util.UUID; //导入方法依赖的package包/类
public String toString(UUID value)
{
    return value == null ? "" : value.toString();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:5,代码来源:UUIDSerializer.java

示例13: setSuite

import java.util.UUID; //导入方法依赖的package包/类
protected void setSuite(UUID id) {
	String serializedSuite = id.toString();
	serialized.addProperty("suite", serializedSuite);
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:5,代码来源:DefaultMartiniResultSerializer.java

示例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));
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:7,代码来源:VirtualChestEconomyManager.java

示例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();
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:7,代码来源:UuidTool.java


注:本文中的java.util.UUID.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。