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
 CompletableFutures. 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.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionA convenience constant for the global context combination (the empty set), if you want your code to look especially fancy.
- 
Method SummaryModifier and TypeMethodDescriptionaddParent(Set<Context> contexts, SubjectReference parent) Adds a parent in a particular context combination.Get all fallback permission values set on this subject dataReturn all options for all context combinations currently registered.Map<Set<Context>,? extends List<? extends SubjectReference>> Return all registered parent subjects for all contexts.Return all permissions associated with this data object.Clear all fallback permission values from this subjectClear all options.clearOptions(Set<Context> contexts) Clear all options in the given context combination.Remove all parents in any context combination.clearParents(Set<Context> contexts) Remove all parents in a given context combination.Clear all permissions set in any context.clearPermissions(Set<Context> contexts) Clear all permissions set in a given context combination.copyFrom(SubjectData other, TransferMethod method) Copy all data from another subject data instance into this one, preserving the original subject.fallbackPermissionValue(Set<Context> contexts) Get the permission value that will be returned if no more specific permission setting matches.booleanReturn if this SubjectData is transient.moveFrom(SubjectData other, TransferMethod method) Move all data from another subject data instance into this one, clearing the source It is expected that the other subject data is provided by the same permissions service.Gets options for a specific context combination.List<? extends SubjectReference>Return all registered parent subjects for a given context.permissions(Set<Context> contexts) Returns the list of permissions set for the given context.removeParent(Set<Context> contexts, SubjectReference parent) Removes a parent in a particular context combination.setFallbackPermissionValue(Set<Context> contexts, Tristate fallback) Set the permission value at the root of the node tree, that will be returned as a response to permissions queries when no more specific permission matches.Sets a specific option to a value.setOptions(Set<Context> contexts, Map<String, String> options, TransferMethod method) Sets all options in a particular context.setParents(Set<Context> contexts, List<? extends SubjectReference> parents, TransferMethod method) Sets the parents in a particular context combination.setPermission(Set<Context> contexts, String permission, Tristate value) Sets a permission to a given value.setPermissions(Set<Context> contexts, Map<String, Boolean> permissions, TransferMethod method) Sets permissions in a given context combination.subject()Gets theSubjectwhich holds this data.
- 
Field Details- 
GLOBAL_CONTEXTA convenience constant for the global context combination (the empty set), if you want your code to look especially fancy.
 
- 
- 
Method Details- 
subjectSubject subject()Gets theSubjectwhich holds this data.- Returns:
- The subject which holds this data
 
- 
isTransientboolean isTransient()Return if this SubjectData is transient.- Returns:
- If this SubjectData is transient
- See Also:
 
- 
allPermissionsReturn all permissions associated with this data object.- Returns:
- An immutable copy of the mappings between contexts and lists of permissions containing every permission registered
 
- 
permissionsReturns the list of permissions set for the given context.This list is immutable and is not a live view. If no permissions have been set, it returns an empty list. - Parameters:
- contexts- The particular context combination to check
- Returns:
- Any permissions set
 
- 
setPermissionSets a permission to a given value.Setting value as Tristate.UNDEFINEDunsets the permission.An empty set of contexts applies this permission to the global context. - Parameters:
- contexts- The particular combination of contexts to set this permission in
- permission- The permission to set
- value- The value to set this permission to
- Returns:
- Whether the operation was successful
 
- 
setPermissionsCompletableFuture<Boolean> setPermissions(Set<Context> contexts, Map<String, Boolean> permissions, TransferMethod method) Sets permissions in a given context combination.An empty set of contexts applies these permissions to the global context. Depending on the TransferMethodchosen, this will either replace all existing options or add to the existing options.- Parameters:
- contexts- The particular combination of contexts to set these permissions in
- permissions- The permissions to set
- method- How to treat existing values in this subject
- Returns:
- Whether the operation was successful
 
- 
fallbackPermissionValueGet the permission value that will be returned if no more specific permission setting matches.- Parameters:
- contexts- The context combination to set this permission in.
- Returns:
- The tristate
 
- 
allFallbackPermissionValuesGet all fallback permission values set on this subject data- Returns:
- An immutable map from context combination to fallback value
 
- 
setFallbackPermissionValueSet the permission value at the root of the node tree, that will be returned as a response to permissions queries when no more specific permission matches.- Parameters:
- contexts- The context combination
- fallback- The new fallback value.- Tristate.UNDEFINEDunsets the fallback value.
- Returns:
- A future completing when the change has been applied
 
- 
clearFallbackPermissionValuesCompletableFuture<Boolean> clearFallbackPermissionValues()Clear all fallback permission values from this subject- Returns:
- A future completing when the change has been applied
 
- 
clearPermissionsCompletableFuture<Boolean> clearPermissions()Clear all permissions set in any context.- Returns:
- Whether any change occurred
 
- 
clearPermissionsClear all permissions set in a given context combination.Passing an empty context set clears permissions in the global context. - Parameters:
- contexts- The context combination to clear permissions in
- Returns:
- Whether any change occurred
 
- 
allParentsMap<Set<Context>,? extends List<? extends SubjectReference>> allParents()Return all registered parent subjects for all 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. - Returns:
- All registered parents and the context they are registered in
 
- 
parentsReturn all registered parent subjects for a given context.The returned list 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. - Parameters:
- contexts- The context to check
- Returns:
- names of parents valid in the given context
 
- 
setParentsCompletableFuture<Boolean> setParents(Set<Context> contexts, List<? extends SubjectReference> parents, TransferMethod method) Sets the parents in a particular context combination.Passing an empty context combination means the parents are set in the global context. Depending on the TransferMethodchosen, this will either replace all existing options or add to the existing options.- Parameters:
- contexts- The context combination this operation is applicable to
- parents- A list of the parents this subject should have
- Returns:
- Whether the operation was successful
 
- 
addParentAdds a parent in a particular context combination.Passing an empty context combination means the parent is added in the global context. - Parameters:
- contexts- The context combination this operation is applicable to
- parent- The name of the parent to add
- Returns:
- Whether the operation was successful
 
- 
removeParentRemoves a parent in a particular context combination.Passing an empty context combination means the parent is removed in the global context. - Parameters:
- contexts- The context combination this operation is applicable to
- parent- The name of the parent to remove
- Returns:
- Whether the operation was successful
 
- 
clearParentsCompletableFuture<Boolean> clearParents()Remove all parents in any context combination.- Returns:
- Whether any change occurred
 
- 
clearParentsRemove all parents in a given context combination.Passing an empty context set clears parents in the global context. - Parameters:
- contexts- The context combination to clear the parents of
- Returns:
- Whether any change occurred
 
- 
allOptionsReturn all options for all context combinations currently registered.- Returns:
- An immutable snapshot of all options data
 
- 
optionsGets options for a specific context combination.- Parameters:
- contexts- The context combination to get options for
- Returns:
- All available options, returning an empty map if none are present
 
- 
setOptionSets a specific option to a value.Passing a null value will unset the option. - Parameters:
- contexts- The context combination to set the given option in
- key- The key to set. Case-insensitive.
- value- The value to set.
- Returns:
- Whether the operation was successful
 
- 
setOptionsCompletableFuture<Boolean> setOptions(Set<Context> contexts, Map<String, String> options, TransferMethod method) Sets all options in a particular context.Depending on the TransferMethodchosen, this will either replace all existing options or add to the existing options.- Parameters:
- contexts- The context combination to set the options in
- options- The map of options to set
- Returns:
- Whether the operation was successful
 
- 
clearOptionsCompletableFuture<Boolean> clearOptions()Clear all options.- Returns:
- Whether the operation was successful
 
- 
clearOptionsClear all options in the given context combination.Passing an empty context set clears options in the global context. - Parameters:
- contexts- The context combination
- Returns:
- Whether the operation was successful (any options were removed)
 
- 
copyFromCopy all data from another subject data instance into this one, preserving the original subject. It is expected that the other subject data is provided by the same permissions service. This methods's behaviour is undefined otherwise.- Parameters:
- other- The other subject to copy data from
- method- How to treat existing values in this subject
- Returns:
- A future completing with trueif the operation is successful
 
- 
moveFromMove all data from another subject data instance into this one, clearing the source It is expected that the other subject data is provided by the same permissions service. This methods's behaviour is undefined otherwise.- Parameters:
- other- The other subject to move data from
- method- How to treat existing values in this subject
- Returns:
- A future completing with trueif the operation is successful
 
 
-