Class SenderTypeValidator
java.lang.Object
com.ultikits.ultitools.abstracts.command.validation.validators.SenderTypeValidator
- All Implemented Interfaces:
CommandValidator
Validates that the command sender matches the expected target type.
- Since:
- 6.2.0
- Version:
- 2.0.0
- Author:
- wisdomme
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.ultikits.ultitools.abstracts.command.validation.CommandValidator
CommandValidator.ValidationResult -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a validator that accepts any sender type.SenderTypeValidator(CmdTarget.CmdTargetType expectedType) Creates a validator for the specified sender type. -
Method Summary
Modifier and TypeMethodDescriptionprivate CmdTarget.CmdTargetTypedetermineTargetType(CommandContext context) Determines the effective target type from context or method annotation.static SenderTypeValidatorfromAnnotation(CmdTarget annotation) Creates a validator from a CmdTarget annotation.getName()Gets the name of this validator for debugging and logging purposes.intgetOrder()Gets the order of this validator.validate(CommandContext context) Validates the command context.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.ultikits.ultitools.abstracts.command.validation.CommandValidator
onComplete, shouldValidate
-
Field Details
-
ORDER
private static final int ORDER- See Also:
-
expectedType
-
-
Constructor Details
-
SenderTypeValidator
public SenderTypeValidator()Creates a validator that accepts any sender type. -
SenderTypeValidator
Creates a validator for the specified sender type.- Parameters:
expectedType- the expected sender type
-
-
Method Details
-
validate
Description copied from interface:CommandValidatorValidates the command context.- Specified by:
validatein interfaceCommandValidator- Parameters:
context- the command context to validate- Returns:
- the validation result
-
determineTargetType
Determines the effective target type from context or method annotation.Delegates to
CmdTargetComposition.resolve(com.ultikits.ultitools.annotations.command.CmdTarget.CmdTargetType, java.lang.reflect.Method), the one place this class-versus-method composition rule is implemented (D-01: narrowing-only override). By the time a matched method reaches here,ComponentScannerhas already refused any class whose composition is ambiguous, so this is a plain lookup - it does not re-validate.- Parameters:
context- the command context- Returns:
- the effective target type
-
getOrder
public int getOrder()Description copied from interface:CommandValidatorGets the order of this validator. Lower values are executed first.- Specified by:
getOrderin interfaceCommandValidator- Returns:
- the order value
-
getName
Description copied from interface:CommandValidatorGets the name of this validator for debugging and logging purposes.- Specified by:
getNamein interfaceCommandValidator- Returns:
- the validator name
-
fromAnnotation
Creates a validator from a CmdTarget annotation.- Parameters:
annotation- the annotation- Returns:
- a new validator
-