Added Reserved UUID class

This commit is contained in:
Luca Frosini 2021-10-21 16:00:58 +02:00
parent 7f5512571c
commit f2fbfc7b66
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package org.gcube.informationsystem.utils;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public final class ReservedUUID {
public static final Set<String> RESERVED_UUID_STRING;
public static final Set<UUID> RESERVED_UUID;
static {
RESERVED_UUID_STRING = new HashSet<>();
RESERVED_UUID = new HashSet<>();
String[] uuidValidCharacters = {"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
for(String string : uuidValidCharacters) {
String uuidString = "00000000-0000-0000-0000-000000000000";
uuidString.replaceAll("0", string);
RESERVED_UUID_STRING.add(uuidString);
RESERVED_UUID.add(UUID.fromString(uuidString));
}
}
public static boolean isReservedUUID(UUID uuid) {
return RESERVED_UUID.contains(uuid);
}
public static boolean isReservedUUID(String uuid) {
return RESERVED_UUID_STRING.contains(uuid);
}
public static Set<String> allUUIDAsString(){
return new HashSet<>(RESERVED_UUID_STRING);
}
public static Set<UUID> allUUID(){
return new HashSet<>(RESERVED_UUID);
}
}