Package io.quarkus.qute
Annotation Type CheckedTemplate
-
@Documented @Retention(RUNTIME) @Target(TYPE) public @interface CheckedTemplate
If you place this annotation on a class, all itsnative staticmethods will be used to declare templates and the list of parameters they require.The name of a method and the base path are used to locate the template contents. By default, the base path is derived from the annotation target:
- If this is placed on a static nested class of an enclosing class with a simple name
X, anative staticmethod of the namefoowill refer to a template at the pathX/foo(template file extensions are not part of the method name) relative to the templates root. - If this is placed on a top-level class, a
native staticmethod of the namefoowill refer to a template at the pathfoo(template file extensions are not part of the method name) at the toplevel of the templates root.
basePath().Each parameter of the
native staticwill be used to validate the template at build time, to make sure that those parameters are used properly in a type-safe manner. The return type of eachnative staticmethod should beTemplateInstance.Example:
@Path("item") public class ItemResource { @CheckedTemplate static class Templates { // defines a template at ItemResource/item, taking an Item parameter named item static native TemplateInstance item(Item item); } @GET @Path("{id}") @Produces(MediaType.TEXT_HTML) public TemplateInstance get(@PathParam("id") Integer id) { // instantiate that template and pass it the required template parameter return Templates.item(service.findItem(id)); } } - If this is placed on a static nested class of an enclosing class with a simple name
-
-
Field Summary
Fields Modifier and Type Fields Description static StringDEFAULTEDConstant value forbasePath()indicating that the default strategy should be used.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description StringbasePathExample:booleanrequireTypeSafeExpressionsIf set to true then the defined templates can only contain type-safe expressions.
-
-
-
Field Detail
-
DEFAULTED
static final String DEFAULTED
Constant value forbasePath()indicating that the default strategy should be used.
-
-
Element Detail
-
basePath
String basePath
Example:@Path("item") public class ItemResource { @CheckedTemplate(basePath = "items_v1") static class Templates { // defines a template at items_v1/item static native TemplateInstance item(Item item); // defines a template at items_v1/allItems static native TemplateInstance allItems(List<Item> items); } }- Returns:
- the base path relative to the templates root
- Default:
- "<<defaulted>>"
-
-