Class RestExtensionBase
java.lang.Object
io.helidon.declarative.codegen.http.RestExtensionBase
A base class for HTTP Rest extensions (server and client).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
computedHeaders
(Set<Annotation> annotations, HttpAnnotated.BuilderBase<?, ?> builder, TypeName repeatedAnnotationType, TypeName singleAnnotationType) Find computed headers in the annotations and set it on the builder.protected void
consumes
(Set<Annotation> annotations, HttpAnnotated.BuilderBase<?, ?> builder) Find consumes in the annotations and set it on the builder.protected Optional
<Annotation> findMetaAnnotated
(TypeName metaAnnotation, Set<Annotation> annotations) Find an annotation with the provided "meta-annotation".headerProducers
(FieldHandler fieldHandler, RestEndpoint endpoint) Find all header producers and create appropriate fields, parameters, and assignments for them.protected void
headers
(Set<Annotation> annotations, HttpAnnotated.BuilderBase<?, ?> builder, TypeName repeatedAnnotationType, TypeName singleAnnotationType) Find headers in the annotations and set it on the builder.protected HttpMethod
httpMethodFromAnnotation
(TypedElementInfo element, Annotation httpMethodAnnotation) Extract HTTP Method from its annotation.protected void
path
(Set<Annotation> annotations, HttpAnnotated.BuilderBase<?, ?> builder) Find path in the annotations and set it on the builder.protected void
produces
(Set<Annotation> annotations, HttpAnnotated.BuilderBase<?, ?> builder) Find produces in the annotations and set it on the builder.protected TypeName
supplierOf
(TypeName type) Create a type name that is a supplier of the provided type.
-
Constructor Details
-
RestExtensionBase
protected RestExtensionBase()Constructor with no side effects.
-
-
Method Details
-
httpMethodFromAnnotation
protected HttpMethod httpMethodFromAnnotation(TypedElementInfo element, Annotation httpMethodAnnotation) Extract HTTP Method from its annotation.- Parameters:
element
- annotated elementhttpMethodAnnotation
- Http method annotation- Returns:
- http method abstraction for code generation
-
path
Find path in the annotations and set it on the builder.- Parameters:
annotations
- all element annotationsbuilder
- element builder
-
consumes
Find consumes in the annotations and set it on the builder.- Parameters:
annotations
- all element annotationsbuilder
- element builder
-
produces
Find produces in the annotations and set it on the builder.- Parameters:
annotations
- all element annotationsbuilder
- element builder
-
headers
protected void headers(Set<Annotation> annotations, HttpAnnotated.BuilderBase<?, ?> builder, TypeName repeatedAnnotationType, TypeName singleAnnotationType) Find headers in the annotations and set it on the builder.- Parameters:
annotations
- all element annotationsbuilder
- element builderrepeatedAnnotationType
- type of the annotation to be found (repeated)singleAnnotationType
- type of the annotation to be found (single)
-
computedHeaders
protected void computedHeaders(Set<Annotation> annotations, HttpAnnotated.BuilderBase<?, ?> builder, TypeName repeatedAnnotationType, TypeName singleAnnotationType) Find computed headers in the annotations and set it on the builder.- Parameters:
annotations
- all element annotationsbuilder
- element builderrepeatedAnnotationType
- type of the annotation to be found (repeated)singleAnnotationType
- type of the annotation to be found (single)
-
supplierOf
Create a type name that is a supplier of the provided type.- Parameters:
type
- type to supply- Returns:
- supplier type
-
headerProducers
Find all header producers and create appropriate fields, parameters, and assignments for them.- Parameters:
fieldHandler
- field handler for the current generated typeendpoint
- rest endpoint to analyze- Returns:
- map of names (as in named services) to field names
-
findMetaAnnotated
protected Optional<Annotation> findMetaAnnotated(TypeName metaAnnotation, Set<Annotation> annotations) Find an annotation with the provided "meta-annotation".- Parameters:
metaAnnotation
- type of the meta annotation we are looking forannotations
- set of annotations on the element- Returns:
- the meta annotation instance, or empty optional if not found
-