public interface SubjectData
This container updates live, and provides raw data for a subject not
taking into account any sort of inheritance. This interface is meant to
represent what's 'in the file', rather than the higher-level query methods
available in Subject
.
Methods which modify the state of the data return
CompletableFuture
s. This allows for the time which is taken to apply
and persist the change to the implementations storage backend. These futures
should return quickly for changes made to transient subject data, but may
take longer to return for changes made to a subjects persistent data. Methods
which use this data in Subject
may not reflect the change until the
future has returned.
CompletableFuture.allOf(CompletableFuture[])
can be used to
combine multiple futures into one, if the result of methods is not
needed.
Modifier and Type | Field and Description |
---|---|
static Set<Context> |
GLOBAL_CONTEXT
A convenience constant for the global context combination (the empty
set), if you want your code to look especially fancy.
|
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Boolean> |
addParent(Set<Context> contexts,
SubjectReference parent)
Adds a parent in a particular context combination.
|
CompletableFuture<Boolean> |
clearOptions()
Clear all options.
|
CompletableFuture<Boolean> |
clearOptions(Set<Context> contexts)
Clear all options in the given context combination.
|
CompletableFuture<Boolean> |
clearParents()
Remove all parents in any context combination.
|
CompletableFuture<Boolean> |
clearParents(Set<Context> contexts)
Remove all parents in a given context combination.
|
CompletableFuture<Boolean> |
clearPermissions()
Clear all permissions set in any context.
|
CompletableFuture<Boolean> |
clearPermissions(Set<Context> contexts)
Clear all permissions set in a given context combination.
|
Map<Set<Context>,Map<String,String>> |
getAllOptions()
Return all options for all context combinations currently registered.
|
Map<Set<Context>,List<SubjectReference>> |
getAllParents()
Return all registered parent subjects for all contexts.
|
Map<Set<Context>,Map<String,Boolean>> |
getAllPermissions()
Return all permissions associated with this data object.
|
Map<String,String> |
getOptions(Set<Context> contexts)
Gets options for a specific context combination.
|
List<SubjectReference> |
getParents(Set<Context> contexts)
Return all registered parent subjects for a given context.
|
Map<String,Boolean> |
getPermissions(Set<Context> contexts)
Returns the list of permissions set for the given context.
|
CompletableFuture<Boolean> |
removeParent(Set<Context> contexts,
SubjectReference parent)
Removes a parent in a particular context combination.
|
CompletableFuture<Boolean> |
setOption(Set<Context> contexts,
String key,
String value)
Sets a specific option to a value.
|
CompletableFuture<Boolean> |
setPermission(Set<Context> contexts,
String permission,
Tristate value)
Sets a permission to a given value.
|
Map<Set<Context>,Map<String,Boolean>> getAllPermissions()
Map<String,Boolean> getPermissions(Set<Context> contexts)
This list is immutable and is not a live view. If no permissions have been set, it returns an empty list.
contexts
- The particular context combination to checkCompletableFuture<Boolean> setPermission(Set<Context> contexts, String permission, Tristate value)
Setting value as Tristate.UNDEFINED
unsets the permission.
An empty set of contexts applies this permission to the global context.
contexts
- The particular combination of contexts to set this
permission inpermission
- The permission to setvalue
- The value to set this permission toCompletableFuture<Boolean> clearPermissions()
CompletableFuture<Boolean> clearPermissions(Set<Context> contexts)
Passing an empty context set clears permissions in the global context.
contexts
- The context combination to clear permissions inMap<Set<Context>,List<SubjectReference>> getAllParents()
The returned map is immutable and not a live view. The results of this method do not traverse any sort of inheritance structure a permissions plugin may implement.
List<SubjectReference> getParents(Set<Context> contexts)
The returned map is immutable and not a live view. The results of this method do not traverse any sort of inheritance structure a permissions plugin may implement.
contexts
- The context to checkCompletableFuture<Boolean> addParent(Set<Context> contexts, SubjectReference parent)
Passing an empty context combination means the parent is added in the global context.
contexts
- The context combination this operation is applicable toparent
- The name of the parent to addCompletableFuture<Boolean> removeParent(Set<Context> contexts, SubjectReference parent)
Passing an empty context combination means the parent is removed in the global context.
contexts
- The context combination this operation is applicable toparent
- The name of the parent to removeCompletableFuture<Boolean> clearParents()
CompletableFuture<Boolean> clearParents(Set<Context> contexts)
Passing an empty context set clears parents in the global context.
contexts
- The context combination to clear the parents ofMap<Set<Context>,Map<String,String>> getAllOptions()
Map<String,String> getOptions(Set<Context> contexts)
contexts
- The context combination to get options forCompletableFuture<Boolean> setOption(Set<Context> contexts, String key, @Nullable String value)
Passing a null value will unset the option.
contexts
- The context combination to set the given option inkey
- The key to set. Case-insensitive.value
- The value to set.CompletableFuture<Boolean> clearOptions()
CompletableFuture<Boolean> clearOptions(Set<Context> contexts)
Passing an empty context set clears options in the global context.
contexts
- The context combination