X-Git-Url: https://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=blobdiff_plain;f=org.argeo.api.uuid%2Fsrc%2Forg%2Fargeo%2Fapi%2Fuuid%2FTypedUuid.java;h=2a0842fe6ef3679f5a82c9827b99441f5113d5b5;hp=55a67abef04dfde862d8b7e9de56e943cb73e950;hb=593a4eabb76b74cd382ecf3f181d57abe0d643f9;hpb=e8e2c65f356b30b35e4d8a1de66691a789c183bb diff --git a/org.argeo.api.uuid/src/org/argeo/api/uuid/TypedUuid.java b/org.argeo.api.uuid/src/org/argeo/api/uuid/TypedUuid.java index 55a67abef..2a0842fe6 100644 --- a/org.argeo.api.uuid/src/org/argeo/api/uuid/TypedUuid.java +++ b/org.argeo.api.uuid/src/org/argeo/api/uuid/TypedUuid.java @@ -4,8 +4,9 @@ import java.util.Objects; 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 @@ -35,7 +36,9 @@ public abstract class TypedUuid extends UuidHolder { /** * 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"); @@ -47,14 +50,15 @@ public abstract class TypedUuid extends UuidHolder { 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."); } } + }