Package net.apartium.cocoabeans.commands
Interface ArgumentConverter<T>
- Type Parameters:
T-
@AvailableSince("0.0.44")
public interface ArgumentConverter<T>
Allows defining custom types in sub commands that will be converted before execution.
For example, if a sub command uses string parser but would like to receive the string argument as a buffer instead, we can create an argument converter to handle that.
The sub command will be able to use the standard string parser but receive an argument buffer instead.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionConvert source object into target type.booleanisSourceTypeSupported(Class<?> clazz) Is argument source type supported by this converter.Target type of this converter.
-
Method Details
-
isSourceTypeSupported
Is argument source type supported by this converter. If an argument is supported, theconvert(Object)method should be able to convert it intotargetType()- Parameters:
clazz- argument source type, cannot be null- Returns:
- true if supported, else false
-
targetType
Target type of this converter.- Returns:
- target type
-
convert
Convert source object into target type. It is guaranteed that objects provided were already checked for source type support.- Parameters:
source- source object- Returns:
- object of target type
-