import java.util.UUID;
/**
- * Base class for objects which are explicitly typed, based on the various UUID
- * versions. Such a derivation hierarchy still represents the {@link UUID}
+ * Base class for objects which are explicitly typed, based on the various
+ * variant 2 (RFC 4122) UUID versions (and variant 6 with {@link GUID}, for
+ * completion). Such a derivation hierarchy still represents the {@link UUID}
* itself, not the objects, data or concept that it identifies. Just like
* {@link UUID}s, {@link TypedUuid} should be used as identifier, not as base
* class for complex objects. It should rather be seen as a framework to build
/**
* Constructs a {@link TypedUuid} of the most appropriate subtype, based on this
- * {@link UUID}.
+ * {@link UUID}. For name based UUIDs, it will return an opaque
+ * {@link BasicNameUuid}; {@link NameUuid} and {@link BinaryNameUuid} may be
+ * more useful.
*/
public static TypedUuid of(UUID uuid) {
Objects.requireNonNull(uuid, "UUID cannot be null");
return new RandomUuid(uuid);
case 3:
case 5:
- return new UnkownNameUuid(uuid);
+ return new BasicNameUuid(uuid);
default:
throw new IllegalArgumentException("UUIDs with version " + uuid.version() + " are not supported.");
}
- } else if (uuid.variant() == 6) {// Microsoft
- throw new IllegalArgumentException("Microsoft UUIDs (aka. GUIDs) are not supported.");
+ } else if (uuid.variant() == 6) {// GUID
+ return new GUID(uuid);
} else {
throw new IllegalArgumentException("UUIDs with variant " + uuid.variant() + " are not supported.");
}
}
+
}