/**
   * Returns an instance of uuid.
   *
   * @param uuid the uuid
   * @return the java.util. uuid
   */
  public static java.util.UUID toUUID(byte[] uuid) {
    long msb = 0;
    long lsb = 0;
    assert uuid.length == 16;
    for (int i = 0; i < 8; i++) msb = (msb << 8) | (uuid[i] & 0xff);
    for (int i = 8; i < 16; i++) lsb = (lsb << 8) | (uuid[i] & 0xff);
    long mostSigBits = msb;
    long leastSigBits = lsb;

    com.eaio.uuid.UUID u = new com.eaio.uuid.UUID(msb, lsb);
    return java.util.UUID.fromString(u.toString());
  }
 /*
  * (non-Javadoc)
  *
  * @see java.lang.Object#hashCode()
  */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((id == null) ? 0 : id.hashCode());
   return result;
 }
  /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;
    if (!(obj instanceof AbstractEntity)) return false;
    AbstractEntity other = (AbstractEntity) obj;
    if (id == null) {
      if (other.id != null) return false;
    } else if (!id.equals(other.id)) return false;

    // if both entity Id's are null we revert to instance equality
    if (id == null && other.id == null) {
      return this == obj;
    }
    return true;
  }
Exemple #4
0
 /**
  * Creates a time-based version 1 UUID.
  *
  * <p>To use this method, it must be able to access a special <a
  * href="http://johannburkard.de/software/uuid/">UUID library</a>. If you use Maven, you should
  * add the following dependency:
  *
  * <blockquote>
  *
  * <pre><code data-type="xml">{@literal
  * <dependency>
  *    <groupId>com.eaio.uuid</groupId>
  *    <artifactId>uuid</artifactId>
  *    <version>3.2</version>
  * </dependency>}</code></pre>
  *
  * </blockquote>
  *
  * @deprecated Use the UUID library directy.
  */
 @Deprecated
 public static UUID createVersion1Uuid() {
   com.eaio.uuid.UUID uuid = new com.eaio.uuid.UUID();
   return new UUID(uuid.getTime(), uuid.getClockSeqAndNode());
 }
Exemple #5
0
 public static com.eaio.uuid.UUID read(org.omg.CORBA.portable.InputStream istream) {
   com.eaio.uuid.UUID value = new com.eaio.uuid.UUID();
   value.time = istream.read_longlong();
   value.clockSeqAndNode = istream.read_longlong();
   return value;
 }