Interface NodePermissionAssigner<S extends Source>
- Type Parameters:
S- the source type that extendsSource, representing the command sender
This interface defines how permissions loaded by a PermissionLoader should be
assigned to individual ParameterNode instances within a command structure.
The assigner is used by the command framework to automatically set appropriate
permissions on command parameters based on the configured permission strategy.
Implementations of this interface determine the logic for how permissions are applied to parameter nodes, allowing for flexible permission assignment strategies such as hierarchical permissions, flat permission structures, or custom logic based on parameter types or command context.
The default implementation uses direct assignment via method reference to
ParameterNode.setPermission(String), but custom implementations can
provide more sophisticated permission assignment logic.
- Since:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default delimiter used to separate permission node segments. -
Method Summary
Modifier and TypeMethodDescriptionvoidassign(@NotNull ParameterNode<S, ?> node, @Nullable String permission) Assigns the specified permission to the given parameter node.static <S extends Source>
@NotNull NodePermissionAssigner<S>Creates a default permission assigner that directly assigns permissions to nodes.default @NotNull StringGets the delimiter used to separate permission node segments.
-
Field Details
-
DEFAULT_DELIMITER
The default delimiter used to separate permission node segments.This constant defines the standard separator character used in hierarchical permission strings (e.g., "command.subcommand.parameter").
- See Also:
-
-
Method Details
-
getPermissionDelimiter
Gets the delimiter used to separate permission node segments.This method returns the character or string used to separate different levels in a hierarchical permission structure. The default implementation returns
DEFAULT_DELIMITER.- Returns:
- the permission delimiter string, never null
-
assign
Assigns the specified permission to the given parameter node.This method is responsible for applying the permission string to the parameter node using the implementation's specific assignment strategy. The permission string is typically loaded by a
PermissionLoaderand represents the required permission for accessing or executing the associated command parameter.Implementations should handle the assignment logic appropriately, which may include validation, transformation, or delegation to other components. The method should be safe to call multiple times on the same node with different permissions.
- Parameters:
node- the parameter node to assign the permission to, must not be nullpermission- the permission string to assign, may be null to clear permissions- Throws:
NullPointerException- ifnodeis nullIllegalArgumentException- if the permission format is invalid for this assigner
-
defaultAssigner
Creates a default permission assigner that directly assigns permissions to nodes.This factory method returns a simple implementation that uses method reference to
ParameterNode.setPermission(String)for direct permission assignment. This is the most straightforward assignment strategy and is suitable for most basic use cases where no custom permission logic is required.The returned assigner will:
- Use the default permission delimiter (
DEFAULT_DELIMITER) - Directly call
ParameterNode.setPermission(String)on the target node - Pass through permission strings without modification
- Type Parameters:
S- the source type that extendsSource- Returns:
- a default implementation of
NodePermissionAssigner, never null - Since:
- 1.0
- Use the default permission delimiter (
-