Tabnine Logo
UUID
Code IndexAdd Tabnine to your IDE (free)

How to use
UUID
in
java.util

Best Java code snippets using java.util.UUID (Showing top 20 results out of 71,694)

Refine searchRefine arrow

  • Game
  • Card
origin: square/okhttp

public Builder() {
 this(UUID.randomUUID().toString());
}
origin: spring-projects/spring-framework

@Override
public UUID convert(String source) {
  return (StringUtils.hasLength(source) ? UUID.fromString(source.trim()) : null);
}
origin: stackoverflow.com

final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
 final String tmDevice, tmSerial, androidId;
 tmDevice = "" + tm.getDeviceId();
 tmSerial = "" + tm.getSimSerialNumber();
 androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
 UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
 String deviceId = deviceUuid.toString();
origin: spring-projects/spring-framework

@Override
public UUID generateId() {
  return UUID.randomUUID();
}
origin: prestodb/presto

  @Override
  public String toString()
  {
    return uuid.toString();
  }
}
origin: apache/incubator-druid

public static void validateIsStandardUUID(
  String uuidString
)
{
 // Since we strip the "-" from the string, we need to break them back out
 final ArrayList<String> strings = new ArrayList<>();
 strings.add(uuidString.substring(0, 8));
 strings.add(uuidString.substring(8, 12));
 strings.add(uuidString.substring(12, 16));
 strings.add(uuidString.substring(16, 20));
 strings.add(uuidString.substring(20, 32));
 UUID uuid = UUID.fromString(Joiner.on('-').join(strings));
 Assert.assertEquals(StringUtils.removeChar(uuid.toString(), '-'), uuidString);
}
origin: spring-projects/spring-framework

@Override
public UUID generateId() {
  byte[] randomBytes = new byte[16];
  this.random.nextBytes(randomBytes);
  long mostSigBits = 0;
  for (int i = 0; i < 8; i++) {
    mostSigBits = (mostSigBits << 8) | (randomBytes[i] & 0xff);
  }
  long leastSigBits = 0;
  for (int i = 8; i < 16; i++) {
    leastSigBits = (leastSigBits << 8) | (randomBytes[i] & 0xff);
  }
  return new UUID(mostSigBits, leastSigBits);
}
origin: spring-projects/spring-framework

private static String generateId() {
  String host;
  try {
    host = InetAddress.getLocalHost().getHostAddress();
  }
  catch (UnknownHostException ex) {
    host = "unknown";
  }
  return host + '-' + UUID.randomUUID();
}
origin: prestodb/presto

  @Override
  @JsonValue
  public String toString()
  {
    return uuid.toString();
  }
}
origin: spring-projects/spring-framework

@Override
public UUID generateId() {
  long leastSigBits = this.leastSigBits.incrementAndGet();
  if (leastSigBits == 0) {
    this.mostSigBits.incrementAndGet();
  }
  return new UUID(this.mostSigBits.get(), leastSigBits);
}
origin: stackoverflow.com

 import java.util.UUID;
String uuid = UUID.randomUUID().toString();
System.out.println("uuid = " + uuid);
origin: square/okhttp

private X500Principal buildSubject() {
 StringBuilder nameBuilder = new StringBuilder();
 if (cn != null) {
  nameBuilder.append("CN=").append(cn);
 } else {
  nameBuilder.append("CN=").append(UUID.randomUUID());
 }
 if (ou != null) {
  nameBuilder.append(", OU=").append(ou);
 }
 return new X500Principal(nameBuilder.toString());
}
origin: spring-projects/spring-framework

/**
 * Create a new session.
 * @param sessionHandler the application handler for the session
 * @param connectHeaders headers for the STOMP CONNECT frame
 */
public DefaultStompSession(StompSessionHandler sessionHandler, StompHeaders connectHeaders) {
  Assert.notNull(sessionHandler, "StompSessionHandler must not be null");
  Assert.notNull(connectHeaders, "StompHeaders must not be null");
  this.sessionId = idGenerator.generateId().toString();
  this.sessionHandler = sessionHandler;
  this.connectHeaders = connectHeaders;
}
origin: swagger-api/swagger-core

@Override
protected UUID cast(Object value) {
  if (value != null) {
    try {
      return UUID.fromString(value.toString());
    } catch (Exception e) {
    }
  }
  return null;
}
origin: vipshop/vjtools

  public static UUID fastUUID() {
    ThreadLocalRandom random = ThreadLocalRandom.current();
    return new UUID(random.nextLong(), random.nextLong());
  }
}
origin: jenkinsci/jenkins

private void init() {
  if(this.uuid == null){
    this.uuid = UUID.randomUUID().toString();
  }
}

origin: spring-projects/spring-framework

@Override
public String addMtomAttachment(DataHandler dataHandler, String elementNamespace, String elementLocalName) {
  String host = getHost(elementNamespace, dataHandler);
  String contentId = UUID.randomUUID() + "@" + host;
  this.mimeContainer.addAttachment("<" + contentId + ">", dataHandler);
  try {
    contentId = URLEncoder.encode(contentId, "UTF-8");
  }
  catch (UnsupportedEncodingException ex) {
    // ignore
  }
  return CID + contentId;
}
origin: spring-projects/spring-framework

/**
 * Create a new {@link JettyWebSocketSession} instance associated with the given user.
 * @param attributes attributes from the HTTP handshake to associate with the WebSocket
 * session; the provided attributes are copied, the original map is not used.
 * @param user the user associated with the session; if {@code null} we'll fallback on the
 * user available via {@link org.eclipse.jetty.websocket.api.Session#getUpgradeRequest()}
 */
public JettyWebSocketSession(Map<String, Object> attributes, @Nullable Principal user) {
  super(attributes);
  this.id = idGenerator.generateId().toString();
  this.user = user;
}
origin: thinkaurelius/titan

  @Override
  public UUID convert(Object value) {
    Preconditions.checkNotNull(value);
    if(value instanceof String){
      return UUID.fromString((String) value);
    }
    return null;
  }
}
origin: google/ExoPlayer

/* package */ SchemeData(Parcel in) {
 uuid = new UUID(in.readLong(), in.readLong());
 licenseServerUrl = in.readString();
 mimeType = in.readString();
 data = in.createByteArray();
 requiresSecureDecryption = in.readByte() != 0;
}
java.utilUUID

Javadoc

UUID is an immutable representation of a 128-bit universally unique identifier (UUID).

There are multiple, variant layouts of UUIDs, but this class is based upon variant 2 of RFC 4122, the Leach-Salz variant. This class can be used to model alternate variants, but most of the methods will be unsupported in those cases; see each method for details.

Most used methods

  • randomUUID
    Generates a variant 2, version 4 (randomly generated number) UUID as perRFC 4122 [http://www.ietf.o
  • toString
    Returns a string representation of this UUID in the following format, as per RFC 4122 [http://www.
  • fromString
    Parses a UUID string with the format defined by #toString().
  • <init>
  • equals
    Compares this UUID to another object for equality. If objectis not null, is a UUID instance, and al
  • getLeastSignificantBits
    The 64 least significant bits of the UUID.
  • getMostSignificantBits
    The 64 most significant bits of the UUID.
  • hashCode
    Returns a hash value for this UUID that is consistent with the #equals(Object) method.
  • nameUUIDFromBytes
    Generates a variant 2, version 3 (name-based, MD5-hashed) UUID as per RFC 4122 [http://www.ietf.org
  • compareTo
    Compares this UUID to the specified UUID. The natural ordering of UUIDs is based upon the value of
  • version
    The version of the variant 2 UUID as per RFC 4122 [http://www.ietf.org/rfc/rfc4122.txt]. If the var
  • timestamp
    The timestamp value of the version 1, variant 2 UUID as per RFC 4122 [http://www.ietf.org/rfc/rfc41
  • version,
  • timestamp,
  • variant,
  • init,
  • makeUuid,
  • clockSequence,
  • node,
  • generateUUIDString

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getApplicationContext (Context)
  • onRequestPermissionsResult (Fragment)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now