Interface CalculatedSubject
-
public interface CalculatedSubject
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Set<ContextValue<?>>activeContexts()@Nullable ObjectassociatedObject()Get a native object associated with this subject.SubjectTypeCollection<?>containingType()Get the subject type holding this calculated subject.SubjectRef.ToData<?>data()Access this subject's persistent data.default booleanhasPermission(String permission)Query whether this subject has a specific permission in this subject's active contexts This method takes into account context and wildcard inheritance calculations for any permission.booleanhasPermission(Set<ContextValue<?>> contexts, String permission)Query whether this subject has a specific permission in the provided contexts This method takes into account context and wildcard inheritance calculations for any permission.SubjectRef<?>identifier()Get the identifier for this subject, as a map entry where the key is the identifier for this subject's type and the value is the specific identifier for this subject.default Optional<String>option(String option)Get an option that may be present for a certain subject in the subject's active contextsOptional<String>option(Set<ContextValue<?>> contexts, String option)Get an option that may be present for a certain subjectdefault org.spongepowered.configurate.ConfigurationNodeoptionNode(String option)Get an option from this subject.org.spongepowered.configurate.ConfigurationNodeoptionNode(Set<ContextValue<?>> contexts, String option)Get an option from this subject.default Map<String,String>options()Get all options for this subject's active contexts.Map<String,String>options(Set<ContextValue<?>> contexts)Get all options for a certain set of contexts.default List<SubjectRef<?>>parents()Get a list of all parents inheriting from this subject in the active contexts.List<SubjectRef<?>>parents(Set<ContextValue<?>> contexts)Get a list of all parents inheriting from this subject.default intpermission(String permission)Query a specific permission in this subject's active contexts This method takes into account context and wildcard inheritance calculations for any permission.intpermission(Set<ContextValue<?>> contexts, String permission)Query a specific permission in a certain set of contexts.default NodeTreepermissions()Get the permissions tree in this subject's active contexts.NodeTreepermissions(Set<ContextValue<?>> contexts)Get the permissions tree for a certain set of contexts.voidregisterListener(Consumer<CalculatedSubject> listener)Register a listener that will receive updates to this subject.SubjectRef.ToData<?>transientData()Access this subject's transient data.voidunregisterListener(Consumer<CalculatedSubject> listener)CompletableFuture<Set<ContextValue<?>>>usedContextValues()
-
-
-
Method Detail
-
identifier
SubjectRef<?> identifier()
Get the identifier for this subject, as a map entry where the key is the identifier for this subject's type and the value is the specific identifier for this subject.- Returns:
- The identifier
-
containingType
SubjectTypeCollection<?> containingType()
Get the subject type holding this calculated subject.- Returns:
- The subject type
-
permissions
default NodeTree permissions()
Get the permissions tree in this subject's active contexts.- Returns:
- A node tree with the calculated permissions
-
permissions
NodeTree permissions(Set<ContextValue<?>> contexts)
Get the permissions tree for a certain set of contexts.- Parameters:
contexts- The contexts to get permissions in- Returns:
- A node tree with the calculated permissions
-
options
default Map<String,String> options()
Get all options for this subject's active contexts. Options are plain strings and therefore do not have wildcard handling.- Returns:
- A map of option keys to values
-
options
Map<String,String> options(Set<ContextValue<?>> contexts)
Get all options for a certain set of contexts. Options are plain strings and therefore do not have wildcard handling.- Parameters:
contexts- The contexts to query- Returns:
- A map of option keys to values
-
parents
default List<SubjectRef<?>> parents()
Get a list of all parents inheriting from this subject in the active contexts.- Returns:
- The list of parents that apply to this subject
-
parents
List<SubjectRef<?>> parents(Set<ContextValue<?>> contexts)
Get a list of all parents inheriting from this subject.- Parameters:
contexts- The contexts to check- Returns:
- The list of parents that apply to this subject
-
activeContexts
Set<ContextValue<?>> activeContexts()
-
usedContextValues
CompletableFuture<Set<ContextValue<?>>> usedContextValues()
-
permission
default int permission(String permission)
Query a specific permission in this subject's active contexts This method takes into account context and wildcard inheritance calculations for any permission.Any checks made through this method will be logged by the
PermissionCheckNotifierregistered with the PEX engine.- Parameters:
permission- The permission to query- Returns:
- The permission value. <0 evaluates to false, 0 is undefined, and >0 evaluates to true.
-
permission
int permission(Set<ContextValue<?>> contexts, String permission)
Query a specific permission in a certain set of contexts. This method takes into account context and wildcard inheritance calculations for any permission.Any checks made through this method will be logged by the
PermissionCheckNotifierregistered with the PEX engine.- Parameters:
contexts- The contexts to check inpermission- The permission to query- Returns:
- The permission value. <0 evaluates to false, 0 is undefined, and >0 evaluates to true.
-
hasPermission
default boolean hasPermission(String permission)
Query whether this subject has a specific permission in this subject's active contexts This method takes into account context and wildcard inheritance calculations for any permission.Any checks made through this method will be logged by the
PermissionCheckNotifierregistered with the PEX engine.- Parameters:
permission- The permission to query- Returns:
- Whether the subject has a true permissions value
-
hasPermission
boolean hasPermission(Set<ContextValue<?>> contexts, String permission)
Query whether this subject has a specific permission in the provided contexts This method takes into account context and wildcard inheritance calculations for any permission.Any checks made through this method will be logged by the
PermissionCheckNotifierregistered with the PEX engine.- Parameters:
contexts- The contexts to query this permission inpermission- The permission to query- Returns:
- Whether the subject has a true permissions value
-
option
default Optional<String> option(String option)
Get an option that may be present for a certain subject in the subject's active contextsAny checks made through this method will be logged by the
PermissionCheckNotifierregistered with the PEX engine.- Parameters:
option- The option to query- Returns:
- The option, if set
-
option
Optional<String> option(Set<ContextValue<?>> contexts, String option)
Get an option that may be present for a certain subjectAny checks made through this method will be logged by the
PermissionCheckNotifierregistered with the PEX engine.- Parameters:
contexts- The contexts to check inoption- The option to query- Returns:
- The option, if set
-
optionNode
default org.spongepowered.configurate.ConfigurationNode optionNode(String option)
Get an option from this subject. The value will be returned as aConfigurationNodeto allow easily accessing its data.Any checks made through this method will be logged by the
PermissionCheckNotifierregistered with the PEX engine.- Parameters:
option- The option to query- Returns:
- The option, if set
-
optionNode
org.spongepowered.configurate.ConfigurationNode optionNode(Set<ContextValue<?>> contexts, String option)
Get an option from this subject. The value will be returned as a ConfigurationNode to allow easily accessing its data. Any checks made through this method will be logged by thePermissionCheckNotifierregistered with the PEX engine.- Parameters:
contexts- The contexts to check inoption- The option to query- Returns:
- The option, if set
-
data
SubjectRef.ToData<?> data()
Access this subject's persistent data.- Returns:
- A reference to the persistent data of this subject
-
transientData
SubjectRef.ToData<?> transientData()
Access this subject's transient data.- Returns:
- A reference to the transient data of this subject
-
associatedObject
@Nullable Object associatedObject()
Get a native object associated with this subject.This object is provided by the
SubjectTyperesponsible for this subject's type.- Returns:
- a native object
-
registerListener
void registerListener(Consumer<CalculatedSubject> listener)
Register a listener that will receive updates to this subject. A reference to the listener will be held, so when updates are no longer needed the listener should be unregistered- Parameters:
listener- The listener
-
unregisterListener
void unregisterListener(Consumer<CalculatedSubject> listener)
-
-