當前位置: 首頁>>代碼示例>>Java>>正文


Java UUID類代碼示例

本文整理匯總了Java中java.util.UUID的典型用法代碼示例。如果您正苦於以下問題:Java UUID類的具體用法?Java UUID怎麽用?Java UUID使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UUID類屬於java.util包,在下文中一共展示了UUID類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFindLargeUpload

import java.util.UUID; //導入依賴的package包/類
@Test
public void testFindLargeUpload() throws Exception {
    final B2Session session = new B2Session(
            new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")
                    )));
    final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path file = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final B2StartLargeFileResponse startResponse = session.getClient().startLargeFileUpload(
            new B2FileidProvider(session).getFileid(bucket, new DisabledListProgressListener()),
            file.getName(), null, Collections.emptyMap());
    assertNotNull(new DefaultAttributesFinderFeature(session).find(file));
    session.getClient().cancelLargeFileUpload(startResponse.getFileId());
    session.close();
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:19,代碼來源:DefaultAttributesFinderFeatureTest.java

示例2: setupAdmin

import java.util.UUID; //導入依賴的package包/類
private void setupAdmin(SpringUserService userService) {

      String username = "admin";
      logger.info("Setup {}", username);

      SpringUser admin;
      Optional<SpringUser> userOptional = userService.findUserByUsername(username);
      if(userOptional.isPresent()){
         admin = userOptional.get();
         String roles = admin.getRoles();
         if(!roles.contains("ROLE_ADMIN") || !roles.contains("ROLE_USER")) {
            admin.setRoles("ROLE_USER,ROLE_ADMIN");
         }
      } else {
         admin = new SpringUserEntity();
         admin.setUsername("admin");
         admin.setRoles("ROLE_USER,ROLE_ADMIN");
         admin.setPassword("admin");
         admin.setEmail("[email protected]");
         admin.setToken(UUID.randomUUID().toString());
         admin.setEnabled(true);
      }

      userService.save(admin);
   }
 
開發者ID:chen0040,項目名稱:spring-boot-slingshot,代碼行數:26,代碼來源:Loader.java

示例3: findReadableCharacteristic

import java.util.UUID; //導入依賴的package包/類
private BluetoothGattCharacteristic findReadableCharacteristic(BluetoothGattService service, UUID characteristicUUID) {
	BluetoothGattCharacteristic characteristic = null;

	int read = BluetoothGattCharacteristic.PROPERTY_READ;

	List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
	for (BluetoothGattCharacteristic c : characteristics) {
		if ((c.getProperties() & read) != 0 && characteristicUUID.equals(c.getUuid())) {
			characteristic = c;
			break;
		}
	}

	// As a last resort, try and find ANY characteristic with this UUID, even if it doesn't have the correct properties
	if (characteristic == null) {
		characteristic = service.getCharacteristic(characteristicUUID);
	}

	return characteristic;
}
 
開發者ID:lenglengiOS,項目名稱:react-native-blue-manager,代碼行數:21,代碼來源:Peripheral.java

示例4: load

import java.util.UUID; //導入依賴的package包/類
/**
 * Gets the stored Forge accounts from the storage
 *
 * @param context calling context
 * @return a hash map of all Forge accounts stored
 */
public static HashMap<UUID, ForgeAccount> load(Context context) {
    // Create new hash map
    HashMap<UUID, ForgeAccount> accounts = new HashMap<>();
    // If storage file exists
    if (context.getFileStreamPath(context.getString(R.string.filename_forge_accounts)).exists()) {
        // Open file stream
        FileInputStream inputStream;
        try {
            inputStream = context.openFileInput(context.getString(R.string.filename_forge_accounts));
            // Open input stream
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
            // Place the file contents into a string
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            StringBuilder stringBuilder = new StringBuilder();
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                stringBuilder.append(line);
            }
            // Initialise GSON
            Gson gson = new Gson();
            // Create a list of Forge Accounts from the JSON string
            List<ForgeAccount> accountList =
                    gson.fromJson(stringBuilder.toString(), new TypeToken<List<ForgeAccount>>() {
                    }.getType());
            // Iterate through each Forge account and add it to the hash map
            for (ForgeAccount account : accountList) {
                accounts.put(account.getId(), account);
            }
        } catch (Exception e) {
            // If there is an error, log it
            Log.e(Forge.ERROR_LOG, e.getMessage());
        }
    }
    return accounts;
}
 
開發者ID:jthomperoo,項目名稱:Forge,代碼行數:42,代碼來源:FileManager.java

示例5: 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

示例6: shouldSetupAttachmentTitleFromAnnotation

import java.util.UUID; //導入依賴的package包/類
@Test
public void shouldSetupAttachmentTitleFromAnnotation() {
    final String uuid = UUID.randomUUID().toString();
    final TestResult result = new TestResult().withUuid(uuid);

    lifecycle.scheduleTestCase(result);
    lifecycle.startTestCase(uuid);

    attachmentWithTitleAndType("parameter value");

    lifecycle.stopTestCase(uuid);
    lifecycle.writeTestCase(uuid);

    assertThat(results.getTestResults())
            .flatExtracting(TestResult::getAttachments)
            .extracting("name", "type")
            .containsExactly(tuple("attachment with parameter value", "text/plain"));

}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:20,代碼來源:Allure1AttachAspectsTest.java

示例7: createLocalizedBillingResourceInDB

import java.util.UUID; //導入依賴的package包/類
private LocalizedBillingResource createLocalizedBillingResourceInDB(
        UUID objID, String locale, String billingResourceDataType,
        byte[] billingResourceValue) throws Exception {
    final LocalizedBillingResource billingResource = createLocalizedBillingResource(
            objID, locale, billingResourceDataType, billingResourceValue);

    runTX(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            ds.persist(billingResource);
            return null;
        }
    });

    return findLocalizedBillingResourceInDB(billingResource);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:17,代碼來源:LocalizedBillingResourceDAOIT.java

示例8: ShardUpsertRequest

import java.util.UUID; //導入依賴的package包/類
public ShardUpsertRequest(ShardId shardId,
                          @Nullable String[] updateColumns,
                          @Nullable Reference[] insertColumns,
                          @Nullable String routing,
                          UUID jobId) {
    super(shardId, routing, jobId);
    assert updateColumns != null || insertColumns != null
            : "Missing updateAssignments, whether for update nor for insert";
    this.updateColumns = updateColumns;
    this.insertColumns = insertColumns;
    if (insertColumns != null) {
        insertValuesStreamer = new Streamer[insertColumns.length];
        for (int i = 0; i < insertColumns.length; i++) {
            insertValuesStreamer[i] = insertColumns[i].valueType().streamer();
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:18,代碼來源:ShardUpsertRequest.java

示例9: copyApk

import java.util.UUID; //導入依賴的package包/類
private static File copyApk(Context context, InputStream inputStream) {
    try {
        File file = new File(getApkDir(context), System.currentTimeMillis() + "_" + UUID.randomUUID() + ".apk");
        OutputStream out = new FileOutputStream(file);
        byte[] buffer = new byte[4096];
        int read;
        while ((read = inputStream.read(buffer)) != -1) {
            out.write(buffer, 0, read);
        }
        inputStream.close();
        inputStream = null;
        out.flush();
        out.close();
        out = null;
        return file;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:LiangMaYong,項目名稱:android-apkbox,代碼行數:21,代碼來源:ApkInstaller.java

示例10: createGraphEntityMutation

import java.util.UUID; //導入依賴的package包/類
private GraphEntityMutation createGraphEntityMutation(BatchMutation batchMutation) {
	GraphEntity.Builder builder = new GraphEntity.Builder();
	Name name = TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME;
	String attributeValue = "Dummy Attribute";
	Metadata metadata = new MockMetadata();
	GraphAttribute graphAttribute = new GraphAttribute(name, attributeValue, metadata);
	builder.addAttribute(graphAttribute);
	Entity.ID newEntityID = Entity.ID.valueOf("urn:entity:" + TartanImplTestConstants.ATTR_PARENT_ID.getName()
			+ "." + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "/" + UUID.randomUUID());
	builder.setID(newEntityID);
	GraphEntity entity = builder.build();

	OperationPipeline assemblyLine = new OperationPipeline();
	NewEntity newEntity = util.createNewEntity(TartanImplTestConstants.ATTR_PARENT_ID);
	CreateEntity createEntity = new CreateEntity(newEntity);
	assemblyLine.add(createEntity);
	
	if(null == batchMutation){
		MutationExecutorFactory factory = new MockMutationExecuterFactory();
		batchMutation = new GraphMutation(factory );
	}
	
	GraphEntityMutation graphEntityMutation = new GraphEntityMutation(entity, assemblyLine, batchMutation);
	return graphEntityMutation;
}
 
開發者ID:intuit,項目名稱:universal-graph-client,代碼行數:26,代碼來源:GraphEntityMutationTest.java

示例11: addsChangeStartingAtExactEndOfThirdSegment

import java.util.UUID; //導入依賴的package包/類
@Test
public void addsChangeStartingAtExactEndOfThirdSegment() {
    this.builder.with(RuleChangeBuilder::input, Arrays.asList("VOICE", "CME", "ED", "UK", "INDEX"));
    this.builder.with(RuleChangeBuilder::output, Collections.singletonList("Rate:2.0"));
    this.builder.with(RuleChangeBuilder::changeRange,
            new DateRange(NOW.plus(Period.ofWeeks(8)), NOW.plus(Period.ofWeeks(9))));

    final List<RuleChange> ruleChanges = this.builder.build();
    assertThat(ruleChanges, hasSize(1));

    final List<RuleChange> originals = getChangesByType(ruleChanges, Type.ORIGINAL);
    assertThat(originals, hasSize(0));

    final List<RuleChange> newChanges = getChangesByType(ruleChanges, Type.NEW);
    assertThat(newChanges, hasSize(1));

    assertRuleChange(newChanges.get(0), Type.NEW, null, new UUID(0, 2),
            new String[]{"VOICE", "CME", "ED", "UK", "INDEX"}, Collections.singletonMap("Rate", "2.0"),
            NOW.plus(Period.ofWeeks(8)), NOW.plus(Period.ofWeeks(9)));
}
 
開發者ID:jpmorganchase,項目名稱:swblocks-decisiontree,代碼行數:21,代碼來源:RuleChangeBuilderTest.java

示例12: getInvoiceCoupons

import java.util.UUID; //導入依賴的package包/類
@GET
    @Path("/{invoiceId}/coupons")
    @Consumes({ "application/json" })
    @Produces({ "application/json", "text/plain" })
    @io.swagger.annotations.ApiOperation(value = "Returns a list of coupon adresses along with their balance.", notes = "", response = AddressValuePair.class, responseContainer = "List", tags={  })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "returns the balance for each coupon", response = AddressValuePair.class, responseContainer = "List"),
        
        @io.swagger.annotations.ApiResponse(code = 404, message = "invoice id not found", response = AddressValuePair.class, responseContainer = "List") })
    public Response getInvoiceCoupons(@ApiParam(value = "the id of the invoice to get the coupons balances for",required=true) @PathParam("invoiceId") UUID invoiceId
,@Context SecurityContext securityContext)
    throws NotFoundException {
        return delegate.getInvoiceCoupons(invoiceId,securityContext);
    }
 
開發者ID:IUNO-TDM,項目名稱:PaymentService,代碼行數:15,代碼來源:InvoicesApi.java

示例13: insertSelectPlayerMetaTest

import java.util.UUID; //導入依賴的package包/類
@Test
public void insertSelectPlayerMetaTest() throws ClassNotFoundException {
    final Plugin plugin = mockPlugin();
    plugin.getConfig().set("sql.enabled", true);
    Factory.initialize(plugin);
    try (PlayerMetaController controller = Factory.createPlayerDataController()) {
        for (final PlayerMeta item : controller.getAll()) {
            controller.remove(item);
        }
        final UUID uuid = UUID.randomUUID();
        final PlayerMeta playerMeta = new PlayerData();

        assertThrows(IllegalArgumentException.class, () -> controller.store(playerMeta));
        assertEquals(0, controller.size());

        playerMeta.setUuid(uuid);
        controller.store(playerMeta);
        assertEquals(0, controller.size());

        playerMeta.setName("Sample");
        controller.store(playerMeta);
        assertEquals(1, controller.size());
        assertEquals(uuid, controller.getById(playerMeta.getId()).getUUID());
    } catch (final Exception e) {
        Logger.getLogger(this.getClass().getSimpleName()).log(Level.WARNING, "Failed to run test.", e);
        Assert.fail();
    }
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:29,代碼來源:PlayerMetaMySQLControllerTest.java

示例14: testConvert

import java.util.UUID; //導入依賴的package包/類
@Test
public void testConvert() {
    final UUID uuid = IdUtils.create();
    final byte[] bytes = IdUtils.toBytes(uuid);

    assertArrayEquals(bytes, converter.convertToDatabaseColumn(uuid));
    assertEquals(uuid, converter.convertToEntityAttribute(bytes));
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:9,代碼來源:UuidConverterTest.java

示例15: getActorGuid

import java.util.UUID; //導入依賴的package包/類
public UUID getActorGuid() {
    try {
        return UUID.fromString(actor);
    } catch (IllegalArgumentException e) {
        return null;
    }
}
 
開發者ID:SAP,項目名稱:cf-java-client-sap,代碼行數:8,代碼來源:CloudEvent.java


注:本文中的java.util.UUID類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。