prompto.store.DataStore Maven / Gradle / Ivy
The newest version!
package prompto.store;
import prompto.store.memory.MemStore;
import prompto.utils.ISingleton;
public abstract class DataStore {
static ISingleton globalInstance = new ISingleton() {
IStore instance = new MemStore();
@Override public void set(IStore instance) { this.instance = instance; }
@Override public IStore get() { return instance; }
};
static ThreadLocal threadInstance = ThreadLocal.withInitial(globalInstance::get);
public static void setGlobal(IStore store) {
globalInstance.set(store);
}
public static void useGlobal() {
threadInstance.set(globalInstance.get());
}
public static void setInstance(IStore store) {
threadInstance.set(store);
}
public static IStore getInstance() {
return threadInstance.get();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy