net.aequologica.neo.shakuntala.UUIDHolder Maven / Gradle / Ivy
package net.aequologica.neo.shakuntala;
import java.util.UUID;
public final class UUIDHolder {
private UUID uuid;
public UUID get() {
return this.uuid;
}
public void setOnce(UUID uuid) {
if (this.uuid != null) {
return;
}
this.uuid = uuid;
}
// 'hand-made' singleton
// cf. https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom
// for the singleton pattern used
// maybe someday, we'll understand enough CDI with maven to remove that shit
private UUIDHolder() {
}
private static class LazyUUIDHolderHolder {
private static final UUIDHolder INSTANCE = new UUIDHolder();
}
public static UUIDHolder getInstance(UUID uuid) {
return LazyUUIDHolderHolder.INSTANCE;
}
public static UUIDHolder getInstance() {
return LazyUUIDHolderHolder.INSTANCE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy