Interface NodePermissionAssigner<S extends Source>

Type Parameters:
S - the source type that extends Source, representing the command sender

public interface NodePermissionAssigner<S extends Source>
Functional interface responsible for assigning permissions to command parameter nodes.

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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The default delimiter used to separate permission node segments.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    assign(@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 String
    Gets the delimiter used to separate permission node segments.
  • Field Details

    • DEFAULT_DELIMITER

      static final String 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

      @NotNull default @NotNull String 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

      void assign(@NotNull @NotNull ParameterNode<S,?> node, @Nullable @Nullable String permission)
      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 PermissionLoader and 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 null
      permission - the permission string to assign, may be null to clear permissions
      Throws:
      NullPointerException - if node is null
      IllegalArgumentException - if the permission format is invalid for this assigner
    • defaultAssigner

      @NotNull static <S extends Source> @NotNull NodePermissionAssigner<S> 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:

      Type Parameters:
      S - the source type that extends Source
      Returns:
      a default implementation of NodePermissionAssigner, never null
      Since:
      1.0