Class AbstractDataStore<T extends AbstractDataStore<T,C>,C>
- java.lang.Object
-
- ca.stellardrift.permissionsex.impl.backend.AbstractDataStore<T,C>
-
- Type Parameters:
T- self typeC- config type
- All Implemented Interfaces:
ca.stellardrift.permissionsex.datastore.DataStore
- Direct Known Subclasses:
FileDataStore,MemoryDataStore
public abstract class AbstractDataStore<T extends AbstractDataStore<T,C>,C> extends Object implements ca.stellardrift.permissionsex.datastore.DataStore
Base implementation of a data store that provides common points for other data stores to hook into.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractDataStore.Factory<T extends AbstractDataStore<T,C>,C>
-
Field Summary
Fields Modifier and Type Field Description protected CacheListenerHolder<Boolean,ca.stellardrift.permissionsex.context.ContextInheritance>contextInheritanceListenersprotected CacheListenerHolder<Map.Entry<String,String>,ca.stellardrift.permissionsex.subject.ImmutableSubjectData>listenersprotected CacheListenerHolder<String,ca.stellardrift.permissionsex.rank.RankLadder>rankLadderListeners
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDataStore(ca.stellardrift.permissionsex.datastore.DataStoreContext context, ca.stellardrift.permissionsex.datastore.ProtoDataStore<C> props)Create the data store.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidapplyDefaultData()Apply default data when creating a new file.protected Cconfig()protected ca.stellardrift.permissionsex.datastore.DataStoreContextcontext()protected ca.stellardrift.permissionsex.PermissionsEngineengine()booleanfirstRun()Stream<Map.Entry<String,ca.stellardrift.permissionsex.subject.ImmutableSubjectData>>getAll(String type)CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance>getContextInheritance(@Nullable Consumer<ca.stellardrift.permissionsex.context.ContextInheritance> listener)protected abstract CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance>getContextInheritanceInternal()CompletableFuture<ca.stellardrift.permissionsex.subject.ImmutableSubjectData>getData(String type, String identifier, @Nullable Consumer<ca.stellardrift.permissionsex.subject.ImmutableSubjectData> listener)protected abstract CompletableFuture<ca.stellardrift.permissionsex.subject.ImmutableSubjectData>getDataInternal(String type, String identifier)CompletableFuture<ca.stellardrift.permissionsex.rank.RankLadder>getRankLadder(String ladderName, @Nullable Consumer<ca.stellardrift.permissionsex.rank.RankLadder> listener)protected abstract CompletableFuture<ca.stellardrift.permissionsex.rank.RankLadder>getRankLadderInternal(String ladder)protected abstract voidload()Load any data necessary to initialize this data store.protected voidmarkFirstRun()Mark that this is the data store's first run.CompletableFuture<Void>moveData(String oldType, String oldIdentifier, String newType, String newIdentifier)Stringname()<V> CompletableFuture<V>performBulkOperation(Function<ca.stellardrift.permissionsex.datastore.DataStore,V> function)protected abstract <V> VperformBulkOperationSync(Function<ca.stellardrift.permissionsex.datastore.DataStore,V> function)Internally perform a bulk operation.protected CompletableFuture<Void>runAsync(Runnable run)protected <V> CompletableFuture<V>runAsync(org.spongepowered.configurate.util.CheckedSupplier<V,?> supplier)CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance>setContextInheritance(ca.stellardrift.permissionsex.context.ContextInheritance contextInheritance)protected abstract CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance>setContextInheritanceInternal(ca.stellardrift.permissionsex.context.ContextInheritance contextInheritance)CompletableFuture<ca.stellardrift.permissionsex.subject.ImmutableSubjectData>setData(String type, String identifier, @Nullable ca.stellardrift.permissionsex.subject.ImmutableSubjectData data)protected abstract CompletableFuture<ca.stellardrift.permissionsex.subject.ImmutableSubjectData>setDataInternal(String type, String identifier, @Nullable ca.stellardrift.permissionsex.subject.ImmutableSubjectData data)CompletableFuture<ca.stellardrift.permissionsex.rank.RankLadder>setRankLadder(String identifier, @Nullable ca.stellardrift.permissionsex.rank.RankLadder ladder)protected abstract CompletableFuture<ca.stellardrift.permissionsex.rank.RankLadder>setRankLadderInternal(String ladder, @Nullable ca.stellardrift.permissionsex.rank.RankLadder newLadder)
-
-
-
Field Detail
-
listeners
protected final CacheListenerHolder<Map.Entry<String,String>,ca.stellardrift.permissionsex.subject.ImmutableSubjectData> listeners
-
rankLadderListeners
protected final CacheListenerHolder<String,ca.stellardrift.permissionsex.rank.RankLadder> rankLadderListeners
-
contextInheritanceListeners
protected final CacheListenerHolder<Boolean,ca.stellardrift.permissionsex.context.ContextInheritance> contextInheritanceListeners
-
-
Constructor Detail
-
AbstractDataStore
protected AbstractDataStore(ca.stellardrift.permissionsex.datastore.DataStoreContext context, ca.stellardrift.permissionsex.datastore.ProtoDataStore<C> props)
Create the data store.No actual loading or creation of threads should be performed here.
- Parameters:
context- the data store contextprops- properties defining this data store
-
-
Method Detail
-
name
public String name()
- Specified by:
namein interfaceca.stellardrift.permissionsex.datastore.DataStore
-
firstRun
public boolean firstRun()
- Specified by:
firstRunin interfaceca.stellardrift.permissionsex.datastore.DataStore
-
markFirstRun
protected void markFirstRun()
Mark that this is the data store's first run.
-
engine
protected final ca.stellardrift.permissionsex.PermissionsEngine engine()
-
context
protected final ca.stellardrift.permissionsex.datastore.DataStoreContext context()
-
load
protected abstract void load() throws ca.stellardrift.permissionsex.exception.PermissionsLoadingException
Load any data necessary to initialize this data store.- Throws:
ca.stellardrift.permissionsex.exception.PermissionsLoadingException- if unable to load
-
getData
public final CompletableFuture<ca.stellardrift.permissionsex.subject.ImmutableSubjectData> getData(String type, String identifier, @Nullable Consumer<ca.stellardrift.permissionsex.subject.ImmutableSubjectData> listener)
- Specified by:
getDatain interfaceca.stellardrift.permissionsex.datastore.DataStore
-
setData
public final CompletableFuture<ca.stellardrift.permissionsex.subject.ImmutableSubjectData> setData(String type, String identifier, @Nullable ca.stellardrift.permissionsex.subject.ImmutableSubjectData data)
- Specified by:
setDatain interfaceca.stellardrift.permissionsex.datastore.DataStore
-
runAsync
protected <V> CompletableFuture<V> runAsync(org.spongepowered.configurate.util.CheckedSupplier<V,?> supplier)
-
runAsync
protected CompletableFuture<Void> runAsync(Runnable run)
-
applyDefaultData
protected final void applyDefaultData()
Apply default data when creating a new file. This consists of- Modifying default data to give all permissions to a user connecting locally
-
getDataInternal
protected abstract CompletableFuture<ca.stellardrift.permissionsex.subject.ImmutableSubjectData> getDataInternal(String type, String identifier)
-
setDataInternal
protected abstract CompletableFuture<ca.stellardrift.permissionsex.subject.ImmutableSubjectData> setDataInternal(String type, String identifier, @Nullable ca.stellardrift.permissionsex.subject.ImmutableSubjectData data)
-
getAll
public final Stream<Map.Entry<String,ca.stellardrift.permissionsex.subject.ImmutableSubjectData>> getAll(String type)
- Specified by:
getAllin interfaceca.stellardrift.permissionsex.datastore.DataStore
-
performBulkOperation
public final <V> CompletableFuture<V> performBulkOperation(Function<ca.stellardrift.permissionsex.datastore.DataStore,V> function)
- Specified by:
performBulkOperationin interfaceca.stellardrift.permissionsex.datastore.DataStore
-
getRankLadder
public final CompletableFuture<ca.stellardrift.permissionsex.rank.RankLadder> getRankLadder(String ladderName, @Nullable Consumer<ca.stellardrift.permissionsex.rank.RankLadder> listener)
- Specified by:
getRankLadderin interfaceca.stellardrift.permissionsex.datastore.DataStore
-
setRankLadder
public final CompletableFuture<ca.stellardrift.permissionsex.rank.RankLadder> setRankLadder(String identifier, @Nullable ca.stellardrift.permissionsex.rank.RankLadder ladder)
- Specified by:
setRankLadderin interfaceca.stellardrift.permissionsex.datastore.DataStore
-
getRankLadderInternal
protected abstract CompletableFuture<ca.stellardrift.permissionsex.rank.RankLadder> getRankLadderInternal(String ladder)
-
setRankLadderInternal
protected abstract CompletableFuture<ca.stellardrift.permissionsex.rank.RankLadder> setRankLadderInternal(String ladder, @Nullable ca.stellardrift.permissionsex.rank.RankLadder newLadder)
-
getContextInheritance
public final CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance> getContextInheritance(@Nullable Consumer<ca.stellardrift.permissionsex.context.ContextInheritance> listener)
- Specified by:
getContextInheritancein interfaceca.stellardrift.permissionsex.datastore.DataStore
-
setContextInheritance
public final CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance> setContextInheritance(ca.stellardrift.permissionsex.context.ContextInheritance contextInheritance)
- Specified by:
setContextInheritancein interfaceca.stellardrift.permissionsex.datastore.DataStore
-
getContextInheritanceInternal
protected abstract CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance> getContextInheritanceInternal()
-
setContextInheritanceInternal
protected abstract CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance> setContextInheritanceInternal(ca.stellardrift.permissionsex.context.ContextInheritance contextInheritance)
-
performBulkOperationSync
protected abstract <V> V performBulkOperationSync(Function<ca.stellardrift.permissionsex.datastore.DataStore,V> function) throws Exception
Internally perform a bulk operation.Safe to call blocking operations from this method -- we're running it asyncly.
- Type Parameters:
V- The- Parameters:
function- The function to run- Returns:
- result of operation, after a save
- Throws:
Exception- if thrown by operation
-
-