Interface ParserFactory
@AvailableSince("0.0.30")
public interface ParserFactory
A factory associated with specific annotations to create argument parsers based on annotations present in the command class
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordRepresents a parser to be registered -
Method Summary
Modifier and TypeMethodDescriptionstatic ParserFactorycreateFromAnnotation(Annotation annotation, boolean onlyClassParser) Create a parser factory from an annotationstatic Map<String, ArgumentParser<?>> findClassParsers(GenericNode node, Class<?> clazz, Map<Class<? extends ParserFactory>, ParserFactory> parserFactories) Get argument parsers from a class@NotNull Collection<ParserFactory.ParserResult> getArgumentParser(GenericNode node, Annotation annotation, GenericDeclaration obj) Construct argument parsers for the given annotationstatic Map<String, ArgumentParser<?>> getArgumentParsers(GenericNode node, Annotation[] annotations, GenericDeclaration obj, boolean limitToClassParsers, Map<Class<? extends ParserFactory>, ParserFactory> parserFactories) Get argument parsers from an array of annotationsstatic Map<String, ArgumentParser<?>> getArgumentParsers(GenericNode node, Annotation annotation, GenericDeclaration obj, boolean limitToClassParsers, Map<Class<? extends ParserFactory>, ParserFactory> parserFactories) Get argument parsers from an annotationstatic Class<? extends ParserFactory> getParserFactoryClass(Annotation annotation) Get the class of the parser factory from an annotation
-
Method Details
-
findClassParsers
@AvailableSince("0.0.37") static Map<String,ArgumentParser<?>> findClassParsers(GenericNode node, Class<?> clazz, Map<Class<? extends ParserFactory>, ParserFactory> parserFactories) Get argument parsers from a class- Parameters:
node- command nodeclazz- target classparserFactories- parser factories for caching- Returns:
- argument parsers
-
getArgumentParsers
@AvailableSince("0.0.37") static Map<String,ArgumentParser<?>> getArgumentParsers(GenericNode node, Annotation[] annotations, GenericDeclaration obj, boolean limitToClassParsers, Map<Class<? extends ParserFactory>, ParserFactory> parserFactories) Get argument parsers from an array of annotations- Parameters:
node- command nodeannotations- annotationsobj- the class / methodlimitToClassParsers- limit to class parsers onlyparserFactories- parser factories for caching- Returns:
- argument parsers
-
getArgumentParsers
@AvailableSince("0.0.37") static Map<String,ArgumentParser<?>> getArgumentParsers(GenericNode node, Annotation annotation, GenericDeclaration obj, boolean limitToClassParsers, Map<Class<? extends ParserFactory>, ParserFactory> parserFactories) Get argument parsers from an annotation- Parameters:
node- command nodeannotation- annotationobj- the class / methodlimitToClassParsers- limit to class parsers onlyparserFactories- parser factories for caching- Returns:
- argument parsers
-
getParserFactoryClass
@AvailableSince("0.0.37") static Class<? extends ParserFactory> getParserFactoryClass(Annotation annotation) Get the class of the parser factory from an annotation- Parameters:
annotation- The annotation that has a CommandParserFactory- Returns:
- The class of the parser factory
-
createFromAnnotation
@AvailableSince("0.0.37") static ParserFactory createFromAnnotation(Annotation annotation, boolean onlyClassParser) Create a parser factory from an annotation- Parameters:
annotation- The annotation that has a CommandParserFactoryonlyClassParser- Whether to only create parsers for classes- Returns:
- The created parser factory
-
getArgumentParser
@NotNull @NotNull Collection<ParserFactory.ParserResult> getArgumentParser(GenericNode node, Annotation annotation, GenericDeclaration obj) Construct argument parsers for the given annotation- Parameters:
node- The node of the command / compound parserannotation- The annotation to construct the argument parser forobj- The annotated element, either a method or a class- Returns:
- A collection of argument parsers to be registered to the scope
-