Class AbstractDataStore<T extends AbstractDataStore<T,​C>,​C>

  • Type Parameters:
    T - self type
    C - 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.
    • 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 context
        props - properties defining this data store
    • Method Detail

      • name

        public String name()
        Specified by:
        name in interface ca.stellardrift.permissionsex.datastore.DataStore
      • firstRun

        public boolean firstRun()
        Specified by:
        firstRun in interface ca.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:
        getData in interface ca.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:
        setData in interface ca.stellardrift.permissionsex.datastore.DataStore
      • runAsync

        protected <V> CompletableFuture<V> runAsync​(org.spongepowered.configurate.util.CheckedSupplier<V,​?> supplier)
      • 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
      • 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:
        getAll in interface ca.stellardrift.permissionsex.datastore.DataStore
      • performBulkOperation

        public final <V> CompletableFuture<V> performBulkOperation​(Function<ca.stellardrift.permissionsex.datastore.DataStore,​V> function)
        Specified by:
        performBulkOperation in interface ca.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:
        getRankLadder in interface ca.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:
        setRankLadder in interface ca.stellardrift.permissionsex.datastore.DataStore
      • getContextInheritance

        public final CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance> getContextInheritance​(@Nullable Consumer<ca.stellardrift.permissionsex.context.ContextInheritance> listener)
        Specified by:
        getContextInheritance in interface ca.stellardrift.permissionsex.datastore.DataStore
      • setContextInheritance

        public final CompletableFuture<ca.stellardrift.permissionsex.context.ContextInheritance> setContextInheritance​(ca.stellardrift.permissionsex.context.ContextInheritance contextInheritance)
        Specified by:
        setContextInheritance in interface ca.stellardrift.permissionsex.datastore.DataStore
      • 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