Interface PermissionsEngine
-
- All Superinterfaces:
ContextDefinitionProvider
public interface PermissionsEngine extends ContextDefinitionProvider
A PermissionsEx engine.- Since:
- 2.0.0
-
-
Field Summary
-
Fields inherited from interface ca.stellardrift.permissionsex.context.ContextDefinitionProvider
GLOBAL_CONTEXT
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static PermissionsEngineBuilder<Void>builder()Create a new builder for an engine.static <C> PermissionsEngineBuilder<C>builder(Class<C> configType)Create a new builder for an engine.default CompletableFuture<ContextInheritance>contextInheritance()Get the current context inheritance.CompletableFuture<ContextInheritance>contextInheritance(@Nullable Consumer<ContextInheritance> listener)Get context inheritance data.CompletableFuture<ContextInheritance>contextInheritance(ContextInheritance newInheritance)Update the context inheritance when values have been changedbooleandebugMode()Get whether or not debug mode is enabled.default voiddebugMode(boolean enabled)Set the active debug mode state.voiddebugMode(boolean enabled, @Nullable Pattern filter)Set the active debug mode state, and a filter.SubjectTypeCollection<SubjectType<?>>defaults()Subjects holding data that will be applied to every subject of a type.<V> CompletableFuture<V>doBulkOperation(Function<DataStore,CompletableFuture<V>> actor)Perform a low-level bulk operation.SubjectTypeCollection<SubjectType<?>>fallbacks()Subjects holding data that will be applied to subjects of each type when no other data is available.Set<SubjectType<?>>knownSubjectTypes()Get all registered subject typesRankLadderCollectionladders()Get a cache for rank ladders known by the engine.Collection<? extends SubjectTypeCollection<?>>loadedSubjectTypes()Get subject types with actively stored data.voidregisterSubjectTypes(SubjectType<?>... types)Register subject types with the engine.default <I> CompletableFuture<CalculatedSubject>subject(SubjectRef<I> reference)Resolve a subject from a reference.<I> SubjectTypeCollection<I>subjects(SubjectType<I> type)Get a subject type by name.-
Methods inherited from interface ca.stellardrift.permissionsex.context.ContextDefinitionProvider
contextDefinition, contextDefinition, registerContextDefinition, registerContextDefinitions, registeredContextTypes, usedContextTypes
-
-
-
-
Method Detail
-
builder
static PermissionsEngineBuilder<Void> builder()
Create a new builder for an engine.- Returns:
- the engine builder
- Since:
- 2.0.0
-
builder
static <C> PermissionsEngineBuilder<C> builder(Class<C> configType)
Create a new builder for an engine.- Returns:
- the engine builder
- Since:
- 2.0.0
-
defaults
SubjectTypeCollection<SubjectType<?>> defaults()
Subjects holding data that will be applied to every subject of a type.- Returns:
- the
fallbacksubject type - Since:
- 2.0.0
-
fallbacks
SubjectTypeCollection<SubjectType<?>> fallbacks()
Subjects holding data that will be applied to subjects of each type when no other data is available.- Returns:
- the
fallbacksubject type - Since:
- 2.0.0
-
registerSubjectTypes
void registerSubjectTypes(SubjectType<?>... types)
Register subject types with the engine.- Parameters:
types- the types to register- Since:
- 2.0.0
-
subjects
<I> SubjectTypeCollection<I> subjects(SubjectType<I> type)
Get a subject type by name.If this subject type has not been seen before, it will be registered.
- Parameters:
type- the type identifier- Returns:
- a subject type instance, never null
- Since:
- 2.0.0
-
subject
default <I> CompletableFuture<CalculatedSubject> subject(SubjectRef<I> reference)
Resolve a subject from a reference.- Type Parameters:
I- identifier type- Parameters:
reference- the subject reference to resolve- Returns:
- a future providing the resolved subject
- Since:
- 2.0.0
-
loadedSubjectTypes
Collection<? extends SubjectTypeCollection<?>> loadedSubjectTypes()
Get subject types with actively stored data.- Returns:
- an unmodifiable view of the actively loaded subject types
-
knownSubjectTypes
Set<SubjectType<?>> knownSubjectTypes()
Get all registered subject types- Returns:
- a stream producing all subject types
- Since:
- 2.0.0
-
ladders
RankLadderCollection ladders()
Get a cache for rank ladders known by the engine.Rank ladders allow for promotion and demotion of a subject among a set of ranked parents.
- Returns:
- the ladder cache
- Since:
- 2.0.0
-
doBulkOperation
<V> CompletableFuture<V> doBulkOperation(Function<DataStore,CompletableFuture<V>> actor)
Perform a low-level bulk operation.This can be used for transforming subjects if the subject type definition changes, and any large data changes that require information that may no longer be valid with current subject type options.
When possible, higher-level bulk query API (not yet written) should be used instead.
- Type Parameters:
V- the result type- Parameters:
actor- the action to perform- Returns:
- a future completing with the result of the action
-
contextInheritance
default CompletableFuture<ContextInheritance> contextInheritance()
Get the current context inheritance.No update listener will be registered
- Returns:
- a future providing the current context inheritance data
- Since:
- 2.0.0
- See Also:
for more details on context inheritance
-
contextInheritance
CompletableFuture<ContextInheritance> contextInheritance(@Nullable Consumer<ContextInheritance> listener)
Get context inheritance data.The result of the future is immutable -- to take effect, the object returned by any update methods in
ContextInheritancemust be passed tocontextInheritance(ContextInheritance). It follows that anybody else's changes will not appear in the returned inheritance object -- so if updates are desired providing a callback function is important.- Parameters:
listener- A callback function that will be triggered whenever there is a change to the context inheritance- Returns:
- A future providing the current context inheritance data
- Since:
- 2.0.0
-
contextInheritance
CompletableFuture<ContextInheritance> contextInheritance(ContextInheritance newInheritance)
Update the context inheritance when values have been changed- Parameters:
newInheritance- The modified inheritance object- Returns:
- A future containing the latest context inheritance object
- Since:
- 2.0.0
-
debugMode
boolean debugMode()
Get whether or not debug mode is enabled.When debug mode is enabled, all permission queries will be logged to the engine's active logger.
- Returns:
- the debug mode state
- Since:
- 2.0.0
-
debugMode
default void debugMode(boolean enabled)
Set the active debug mode state.- Parameters:
enabled- whether debug mode is enabled- Since:
- 2.0.0
- See Also:
for information on the consequences of debug mode
-
debugMode
void debugMode(boolean enabled, @Nullable Pattern filter)
Set the active debug mode state, and a filter.- Parameters:
enabled- whether debug mode is enabledfilter- a filter for values (permissions, options, and subject names) that will be logged by debug mode.- Since:
- 2.0.0
- See Also:
for information on the consequences of debug mode
-
-