public abstract class AbstractParameterProcessor extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractParameterProcessor.ParameterContext
Used for collecting and merging any scanned
Parameter annotations
with the framework-specific parameter annotations. |
protected static class |
AbstractParameterProcessor.ParameterContextKey
Key used to store
AbstractParameterProcessor.ParameterContext objects in a map sorted by Parameter.In,
then by name, nulls first. |
| Modifier and Type | Field and Description |
|---|---|
protected ClassLoader |
cl |
protected List<AnnotationScannerExtension> |
extensions |
protected String |
formMediaType
The media type of a form schema found while scanning the parameters.
|
protected Map<String,org.jboss.jandex.AnnotationInstance> |
formParams
Collection of form parameters found during scanning.
|
protected org.jboss.jandex.IndexView |
index |
protected Map<String,Map<String,org.jboss.jandex.AnnotationInstance>> |
matrixParams
Collection of matrix parameters found during scanning.
|
protected Map<AbstractParameterProcessor.ParameterContextKey,AbstractParameterProcessor.ParameterContext> |
params
Collection of parameters scanned at the current level.
|
protected Function<org.jboss.jandex.AnnotationInstance,org.eclipse.microprofile.openapi.models.parameters.Parameter> |
readerFunction |
protected AnnotationScannerContext |
scannerContext |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractParameterProcessor(AnnotationScannerContext scannerContext,
Function<org.jboss.jandex.AnnotationInstance,org.eclipse.microprofile.openapi.models.parameters.Parameter> reader,
List<AnnotationScannerExtension> extensions) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addEncoding(Map<String,org.eclipse.microprofile.openapi.models.media.Encoding> encodings,
String paramName,
org.jboss.jandex.AnnotationTarget paramTarget)
Determine if the paramTarget is annotated with the RestEasy
PartType
annotation and add the value to the encodings map. |
protected String |
fullPathOf(org.jboss.jandex.AnnotationTarget target)
Find the full path of the target.
|
protected String |
generatePath(org.jboss.jandex.AnnotationTarget target,
List<org.eclipse.microprofile.openapi.models.parameters.Parameter> parameters)
Generate the path for the provided annotation target, either a class or a method.
|
protected org.jboss.jandex.DotName |
getDefaultAnnotationName() |
protected String |
getDefaultAnnotationProperty() |
protected String |
getDefaultFormMediaType() |
protected Object |
getDefaultValue(org.jboss.jandex.AnnotationTarget target)
Scan and parse a default value annotation.
|
protected org.eclipse.microprofile.openapi.models.media.Content |
getFormBodyContent()
Create a
Content and use the scanned form parameters
as the properties. |
protected abstract FrameworkParameter |
getMatrixParameter() |
protected List<org.eclipse.microprofile.openapi.models.parameters.Parameter> |
getParameters(org.jboss.jandex.MethodInfo resourceMethod)
Performs the final merging of framework parameters with MP-OAI parameters to produce the list
of
Parameters found while scanning the current level (class or method). |
protected abstract Pattern |
getTemplateParameterPattern() |
protected static org.jboss.jandex.Type |
getType(org.jboss.jandex.AnnotationTarget target)
Determines the type of the target.
|
protected AbstractParameterProcessor.ParameterContext |
getUnannotatedPathParameter(org.jboss.jandex.MethodInfo resourceMethod,
String name) |
protected boolean |
hasParameters(Collection<org.jboss.jandex.AnnotationInstance> annotations)
Check for the existence relevant parameter annotations in the collection.
|
protected boolean |
isIgnoredParameter(org.eclipse.microprofile.openapi.models.parameters.Parameter parameter,
org.jboss.jandex.AnnotationTarget resourceMethod)
Determine if this is an ignored parameter, per the MP+OAI specification in
@Parameter. |
protected abstract boolean |
isParameter(org.jboss.jandex.DotName annotationName) |
protected boolean |
isReadableParameterAnnotation(org.jboss.jandex.DotName name) |
protected abstract boolean |
isResourceMethod(org.jboss.jandex.MethodInfo method)
Determines if the given method is a framework resource method annotated by one
of the HTTP method annotations.
|
protected abstract boolean |
isSubResourceLocator(org.jboss.jandex.MethodInfo method)
Determines if the given method is a sub-resource locator method
annotated by
@Path but NOT annotated with one of the HTTP method
annotations. |
protected String |
lastPathSegmentOf(org.jboss.jandex.AnnotationTarget target)
Retrieves the last path segment of the full path associated with the target.
|
protected static String |
paramName(org.jboss.jandex.AnnotationInstance annotation)
Retrieves the "value" parameter from annotation to be used as the name.
|
protected abstract String |
pathOf(org.jboss.jandex.AnnotationTarget target)
Reads the framework's path annotation present on the
target and strips leading and trailing slashes.
|
protected Object |
primitiveToObject(org.jboss.jandex.PrimitiveType.Primitive primitive,
String stringValue) |
protected ResourceParameters |
process(org.jboss.jandex.ClassInfo resourceClass,
org.jboss.jandex.MethodInfo resourceMethod) |
protected void |
processFinalize(org.jboss.jandex.ClassInfo resourceClass,
org.jboss.jandex.MethodInfo resourceMethod,
ResourceParameters parameters) |
protected void |
processOperationParameters(org.jboss.jandex.MethodInfo resourceMethod,
ResourceParameters parameters) |
protected void |
processPathParameters(org.jboss.jandex.ClassInfo resourceClass,
org.jboss.jandex.MethodInfo resourceMethod,
ResourceParameters parameters) |
protected void |
readAnnotatedType(org.jboss.jandex.AnnotationInstance annotation)
Read a single annotation that is either
{@literal @}Parameter or
one of the framework parameter annotations. |
protected abstract void |
readAnnotatedType(org.jboss.jandex.AnnotationInstance annotation,
org.jboss.jandex.AnnotationInstance beanParamAnnotation,
boolean overriddenParametersOnly)
Read a single annotation that is either
{@literal @}Parameter or
one of the framework parameter annotations. |
protected void |
readParameter(AbstractParameterProcessor.ParameterContextKey key,
org.eclipse.microprofile.openapi.models.parameters.Parameter oaiParam,
FrameworkParameter frameworkParam,
Object defaultValue,
org.jboss.jandex.AnnotationTarget target,
boolean overriddenParametersOnly)
Merges MP-OAI
Parameters and framework-specific parameters for the same Parameter.In and name,
and Parameter.Style. |
protected void |
readParameterAnnotation(org.jboss.jandex.AnnotationInstance annotation)
Read a single annotation that is either
{@literal @}Parameter or
{@literal @}Parameters. |
protected void |
readParameterAnnotation(org.jboss.jandex.AnnotationInstance annotation,
boolean overriddenParametersOnly) |
protected void |
readParameters(org.jboss.jandex.ClassInfo clazz,
org.jboss.jandex.AnnotationInstance beanParamAnnotation,
boolean overriddenParametersOnly)
Scans for class level parameters.
|
protected void |
readParametersInherited(org.jboss.jandex.ClassInfo clazz,
org.jboss.jandex.AnnotationInstance beanParamAnnotation,
boolean overriddenParametersOnly)
Scans for class level parameters on the given class argument and its ancestors.
|
protected void |
reset() |
protected org.jboss.jandex.Type |
resolveType(org.jboss.jandex.Type targetType)
Attempt to resolve the type of targetType, using the full stack of resolvers
from the scanning context.
|
protected void |
setMediaType(FrameworkParameter frameworkParam)
Set this
AbstractParameterProcessor's formMediaType if it has not already
been set and the value is explicitly known for the parameter type. |
protected void |
setSchemaProperties(org.eclipse.microprofile.openapi.models.media.Schema schema,
Map<String,org.eclipse.microprofile.openapi.models.media.Encoding> encodings,
Map<String,org.jboss.jandex.AnnotationInstance> params,
boolean schemaAnnotationSupported)
Converts the collection of parameter annotations to properties set on the
given schema.
|
protected static org.eclipse.microprofile.openapi.models.parameters.Parameter.Style |
styleOf(org.eclipse.microprofile.openapi.models.parameters.Parameter param)
Retrieves either the provided parameter
Parameter.Style, the default
style of the parameter based on the in attribute, or null if in is not defined. |
protected final AnnotationScannerContext scannerContext
protected final org.jboss.jandex.IndexView index
protected final ClassLoader cl
protected final Function<org.jboss.jandex.AnnotationInstance,org.eclipse.microprofile.openapi.models.parameters.Parameter> readerFunction
protected final List<AnnotationScannerExtension> extensions
protected Map<AbstractParameterProcessor.ParameterContextKey,AbstractParameterProcessor.ParameterContext> params
protected Map<String,org.jboss.jandex.AnnotationInstance> formParams
APIResponse
if a value has not be provided by the application.protected String formMediaType
protected AbstractParameterProcessor(AnnotationScannerContext scannerContext, Function<org.jboss.jandex.AnnotationInstance,org.eclipse.microprofile.openapi.models.parameters.Parameter> reader, List<AnnotationScannerExtension> extensions)
protected void reset()
protected ResourceParameters process(org.jboss.jandex.ClassInfo resourceClass, org.jboss.jandex.MethodInfo resourceMethod)
protected void processPathParameters(org.jboss.jandex.ClassInfo resourceClass,
org.jboss.jandex.MethodInfo resourceMethod,
ResourceParameters parameters)
protected void processOperationParameters(org.jboss.jandex.MethodInfo resourceMethod,
ResourceParameters parameters)
protected void processFinalize(org.jboss.jandex.ClassInfo resourceClass,
org.jboss.jandex.MethodInfo resourceMethod,
ResourceParameters parameters)
protected String generatePath(org.jboss.jandex.AnnotationTarget target, List<org.eclipse.microprofile.openapi.models.parameters.Parameter> parameters)
target - the target (either class or method)parameters - list of all parameters processedprotected abstract Pattern getTemplateParameterPattern()
protected List<org.eclipse.microprofile.openapi.models.parameters.Parameter> getParameters(org.jboss.jandex.MethodInfo resourceMethod)
Parameters found while scanning the current level (class or method).resourceMethod - the method to which the returned parameters are applicableParametersprotected abstract FrameworkParameter getMatrixParameter()
protected AbstractParameterProcessor.ParameterContext getUnannotatedPathParameter(org.jboss.jandex.MethodInfo resourceMethod, String name)
resourceMethod - method potentially containing an un-annotated path parameter argumentname - name of the path parameter without any associated annotationsprotected org.jboss.jandex.Type resolveType(org.jboss.jandex.Type targetType)
targetType - the type to resolveprotected void setSchemaProperties(org.eclipse.microprofile.openapi.models.media.Schema schema,
Map<String,org.eclipse.microprofile.openapi.models.media.Encoding> encodings,
Map<String,org.jboss.jandex.AnnotationInstance> params,
boolean schemaAnnotationSupported)
schema - the Schema on which the properties will be setencodings - map of encodings applicable to the current MediaType being processedparams - the name/value pairs of annotations for conversion to schema propertiesschemaAnnotationSupported - true if the parameter supports a co-located @Schema annotationprotected org.eclipse.microprofile.openapi.models.media.Content getFormBodyContent()
Content and use the scanned form parameters
as the properties. The media type will be determined by the framework's
subclass - e.g. for JAX-RS it may be defaulted to 'application/x-www-form-urlencoded' or set
to 'multipart/form-data' if a
RESTEasy MultipartForm
annotation was used to wrap the javax.ws.rs.FormParams. The encoding values
for the Content will be set to the value of any RESTEasy PartType
annotations found for each parameter.protected String getDefaultFormMediaType()
protected void addEncoding(Map<String,org.eclipse.microprofile.openapi.models.media.Encoding> encodings, String paramName, org.jboss.jandex.AnnotationTarget paramTarget)
PartType
annotation and add the value to the encodings map.encodings - map of encodings applicable to the current MediaType being processedparamName - name of the current form parameter being mapped to a schema propertyparamTarget - the target annotated with the framework's form annotationprotected boolean isIgnoredParameter(org.eclipse.microprofile.openapi.models.parameters.Parameter parameter,
org.jboss.jandex.AnnotationTarget resourceMethod)
@Parameter.
Path parameters that do not have a corresponding path segment will be ignored.parameter - the parameter to determine if ignoredresourceMethod - the resource method to which the parameter may applyParameter.name(),
Parameter.in()protected void readParameterAnnotation(org.jboss.jandex.AnnotationInstance annotation)
{@literal @}Parameter or
{@literal @}Parameters. The results are stored
in the private params
collection.annotation - a parameter annotation to be read and processedprotected void readAnnotatedType(org.jboss.jandex.AnnotationInstance annotation)
{@literal @}Parameter or
one of the framework parameter annotations. The results are stored in the
private params collection, depending on the type of parameter.annotation - a parameter annotation to be read and processedprotected abstract void readAnnotatedType(org.jboss.jandex.AnnotationInstance annotation,
org.jboss.jandex.AnnotationInstance beanParamAnnotation,
boolean overriddenParametersOnly)
{@literal @}Parameter or
one of the framework parameter annotations. The results are stored in the
private params collection. When overriddenParametersOnly is true,
new parameters not already known in params will be ignored.annotation - a parameter annotation to be read and processedbeanParamAnnotation - a framework's bean-type (POJO) parameter annotationoverriddenParametersOnly - true if only parameters already known to the scanner are considered, false otherwiseprotected static org.eclipse.microprofile.openapi.models.parameters.Parameter.Style styleOf(org.eclipse.microprofile.openapi.models.parameters.Parameter param)
Parameter.Style, the default
style of the parameter based on the in attribute, or null if in is not defined.param - the Parameterin, or null if in is not defined.protected void setMediaType(FrameworkParameter frameworkParam)
AbstractParameterProcessor's formMediaType if it has not already
been set and the value is explicitly known for the parameter type.frameworkParam - parameter to check for a form media typeprotected static String paramName(org.jboss.jandex.AnnotationInstance annotation)
annotation - parameter annotationprotected org.jboss.jandex.DotName getDefaultAnnotationName()
protected String getDefaultAnnotationProperty()
protected Object getDefaultValue(org.jboss.jandex.AnnotationTarget target)
target - target annotated with a parameter annotationprotected Object primitiveToObject(org.jboss.jandex.PrimitiveType.Primitive primitive, String stringValue)
protected String lastPathSegmentOf(org.jboss.jandex.AnnotationTarget target)
target - protected String fullPathOf(org.jboss.jandex.AnnotationTarget target)
target - target item for which the path is being generatedprotected abstract String pathOf(org.jboss.jandex.AnnotationTarget target)
target - target objectprotected static org.jboss.jandex.Type getType(org.jboss.jandex.AnnotationTarget target)
target - target objectprotected boolean isReadableParameterAnnotation(org.jboss.jandex.DotName name)
protected void readParameterAnnotation(org.jboss.jandex.AnnotationInstance annotation,
boolean overriddenParametersOnly)
protected void readParameter(AbstractParameterProcessor.ParameterContextKey key, org.eclipse.microprofile.openapi.models.parameters.Parameter oaiParam, FrameworkParameter frameworkParam, Object defaultValue, org.jboss.jandex.AnnotationTarget target, boolean overriddenParametersOnly)
Parameters and framework-specific parameters for the same Parameter.In and name,
and Parameter.Style. When overriddenParametersOnly is true, new parameters not already known
in params will be ignored.
The given key contains:
@Parameter.in
or implied by the type of framework annotation used on the target
key - the key for the parameter being processedoaiParam - scanned @ParameterframeworkParam - Meta detail about the framework parameter being processed, if found.defaultValue - value read from the framework's default-value annotation.target - target of the annotationoverriddenParametersOnly - true if only parameters already known to the scanner are considered, false otherwiseprotected void readParametersInherited(org.jboss.jandex.ClassInfo clazz,
org.jboss.jandex.AnnotationInstance beanParamAnnotation,
boolean overriddenParametersOnly)
clazz - the class to be scanned for parameters.beanParamAnnotation - the bean parameter annotation to be used for path derivationoverriddenParametersOnly - true if only parameters already known to the scanner are considered, false otherwiseprotected void readParameters(org.jboss.jandex.ClassInfo clazz,
org.jboss.jandex.AnnotationInstance beanParamAnnotation,
boolean overriddenParametersOnly)
clazz - the class to be scanned for parameters.beanParamAnnotation - the bean parameter annotation to be used for path derivationoverriddenParametersOnly - true if only parameters already known to the scanner are considered, false otherwiseprotected abstract boolean isSubResourceLocator(org.jboss.jandex.MethodInfo method)
@Path but NOT annotated with one of the HTTP method
annotations.method - method to checkprotected abstract boolean isResourceMethod(org.jboss.jandex.MethodInfo method)
method - method to checkprotected boolean hasParameters(Collection<org.jboss.jandex.AnnotationInstance> annotations)
annotations - collection of annotationsprotected abstract boolean isParameter(org.jboss.jandex.DotName annotationName)
Copyright © 2018–2021. All rights reserved.