Example usage for java.util UUID randomUUID

List of usage examples for java.util UUID randomUUID

Introduction

In this page you can find the example usage for java.util UUID randomUUID.

Prototype

public static UUID randomUUID() 

Source Link

Document

Static factory to retrieve a type 4 (pseudo randomly generated) UUID.

Usage

From source file:net.dovemq.transport.link.LinkTestUtils.java

public static CAMQPMessage createMessage(Random randomGenerator) {
    String deliveryTag = UUID.randomUUID().toString();
    int sectionSize = 256 * (randomGenerator.nextInt(10) + 1);
    String str = RandomStringUtils.randomAlphanumeric(sectionSize);
    CAMQPMessagePayload payload = new CAMQPMessagePayload(str.getBytes());
    return new CAMQPMessage(deliveryTag, payload);
}

From source file:ch.aonyx.broker.ib.api.util.StringIdUtils.java

/**
 * Random string id based on {@link UUID}.
 *//*from   w  ww  . j a v  a 2  s  .c o m*/
public static String uniqueRandomId() {
    final String id = UUID.randomUUID().toString();
    if (UNIQUE_IDS.contains(id)) {
        return uniqueRandomId();
    }
    UNIQUE_IDS.add(id);
    return id;
}

From source file:alfio.controller.support.SessionUtil.java

public static void saveSpecialPriceCode(String specialPriceCode, HttpServletRequest request) {
    if (StringUtils.isNotEmpty(specialPriceCode)) {
        request.getSession().setAttribute(SPECIAL_PRICE_CODE_SESSION_ID, UUID.randomUUID().toString());
        request.getSession().setAttribute(SPECIAL_PRICE_CODE, specialPriceCode);
    }//ww  w .  j  av  a  2  s  .co  m
}

From source file:com.vehicles.domain.entities.Order.java

public Order() {
    this.id = UUID.randomUUID().toString();
}

From source file:fi.hsl.parkandride.MDCFilter.java

private static void setValues(ServletRequest request) {
    HttpServletRequest httpReq = HttpServletRequest.class.cast(request);
    MDC.put(Key.REQUESTID, UUID.randomUUID().toString());
    MDC.put(Key.SRCIP, httpReq.getRemoteHost());
    // Authenticated username will be set in UserArgumentResolver iff authentication is required
    MDC.put(Key.USERNAME, "<ANONYMOUS>");
    String appId = httpReq.getHeader(LIIPI_APPLICATION_ID);
    if (appId != null) {
        MDC.put(Key.APPID, appId);
    }//w  w w  .j a  va  2s.c  o  m
}

From source file:org.opensafety.hishare.managers.implementation.remoting.PayloadManagerImpl.java

public static String createTransferKey() {
    return UUID.randomUUID().toString();
}

From source file:com.mobileman.kuravis.core.util.security.SecurityUtils.java

/**
 * @param length//from   ww  w . j av  a 2 s. c  o m
 * @return random string
 */
public static String getRandomString(int length) {
    String result = "";

    UUID uuid = UUID.randomUUID();
    result = uuid.toString().substring(0, length);

    return result;
}

From source file:Main.java

/**
 * Gets an unique id for installation//from  w  w w  . j  a  v a2  s  .c o  m
 *
 * @return the unique id
 */
@Nullable
public static synchronized String getInstallationId(@NonNull Context context) {
    if (uniqueID == null) {
        SharedPreferences sharedPrefs = context.getSharedPreferences(PREF_UNIQUE_ID, Context.MODE_PRIVATE);
        uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);

        if (uniqueID == null) {
            uniqueID = UUID.randomUUID().toString();
            SharedPreferences.Editor editor = sharedPrefs.edit();
            editor.putString(PREF_UNIQUE_ID, uniqueID);
            editor.apply();
        }
    }

    return uniqueID;
}

From source file:ai.grakn.test.docs.DocTestUtil.java

public static GraknSession getTestGraph(String uri) {
    String keyspace = UUID.randomUUID().toString().replaceAll("-", "");
    GraknSession session = Grakn.session(uri, keyspace);

    try (GraknGraph graph = session.open(GraknTxType.WRITE)) {
        GenealogyGraph.get().accept(graph);

        // TODO: Remove custom genealogy ontology when not used
        ResourceType<Long> age = graph.putResourceType("age", ResourceType.DataType.LONG);
        graph.getEntityType("person").resource(age);
        graph.putResourceType("nickname", ResourceType.DataType.STRING);

        // TODO: Remove plant ontology when not used
        EntityType plant = graph.putEntityType("plant");
        ResourceType<String> common = graph.putResourceType("common", ResourceType.DataType.STRING);
        ResourceType<String> botanical = graph.putResourceType("botanical", ResourceType.DataType.STRING);
        ResourceType<String> zone = graph.putResourceType("zone", ResourceType.DataType.STRING);
        ResourceType<String> light = graph.putResourceType("light", ResourceType.DataType.STRING);
        ResourceType<Long> availability = graph.putResourceType("availability", ResourceType.DataType.LONG);
        plant.resource(common).resource(botanical).resource(zone).resource(light).resource(availability);

        // TODO: Remove pokemon ontology when not used
        EntityType pokemon = graph.putEntityType("pokemon");
        EntityType pokemonType = graph.putEntityType("pokemon-type");

        ResourceType<String> typeId = graph.putResourceType("type-id", ResourceType.DataType.STRING);
        ResourceType<String> description = graph.putResourceType("description", ResourceType.DataType.STRING);
        ResourceType<Long> pokedexNo = graph.putResourceType("pokedex-no", ResourceType.DataType.LONG);
        ResourceType<Double> weight = graph.putResourceType("weight", ResourceType.DataType.DOUBLE);
        ResourceType<Double> height = graph.putResourceType("height", ResourceType.DataType.DOUBLE);

        graph.putRelationType("has-type").relates(graph.putRole("type-of-pokemon"))
                .relates(graph.putRole("pokemon-with-type"));

        pokemonType.resource(typeId).resource(description);
        pokemon.resource(weight).resource(height).resource(pokedexNo).resource(description);

        // TODO: Remove these random types when not used
        graph.putEntityType("cluster");

        graph.commit();/*from w  w  w  .j ava  2s.  c  o m*/
    }

    return session;
}

From source file:com.hangum.tadpole.commons.util.Utils.java

/**
 * unique id  . 
 * 
 * @param length
 * @return
 */
public static String getUniqueID() {
    return UUID.randomUUID().toString();
}