Package io.wcm.wcm.commons.util
Class Template
- java.lang.Object
-
- io.wcm.wcm.commons.util.Template
-
@ProviderType public final class Template extends java.lang.Object
Template utility methods
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @Nullable TemplatePathInfo
forPage(@NotNull com.day.cq.wcm.api.Page page, @NotNull TemplatePathInfo @NotNull ... templates)
Lookup template for given page.static <E extends java.lang.Enum<E> & TemplatePathInfo>
@Nullable TemplatePathInfoforPage(@NotNull com.day.cq.wcm.api.Page page, @NotNull java.lang.Class<E> @NotNull ... templateEnums)
Lookup template for given page.static @Nullable TemplatePathInfo
forTemplatePath(@NotNull java.lang.String templatePath, @NotNull TemplatePathInfo @NotNull ... templates)
Lookup a template by the given template path.static <E extends java.lang.Enum<E> & TemplatePathInfo>
@Nullable TemplatePathInfoforTemplatePath(@NotNull java.lang.String templatePath, @NotNull java.lang.Class<E> @NotNull ... templateEnums)
Lookup a template by the given template path.static @Nullable java.lang.String
getResourceTypeFromTemplatePath(@NotNull java.lang.String templatePath)
Gets the resource type for a given template path.static boolean
is(@NotNull com.day.cq.wcm.api.Page page, @NotNull TemplatePathInfo @NotNull ... templates)
Checks if the given page uses a specific template.static boolean
is(@NotNull com.day.cq.wcm.api.Page page, @NotNull java.lang.String @NotNull ... templatePaths)
Checks if the given page uses a specific template.
-
-
-
Method Detail
-
getResourceTypeFromTemplatePath
@Nullable public static @Nullable java.lang.String getResourceTypeFromTemplatePath(@NotNull @NotNull java.lang.String templatePath)
Gets the resource type for a given template path.This is based on the assumption that:
- Given a template path is
/apps/{app_path}/templates/{optional_path}/{template_path}
- Then the resource path is at
{app_path}/components/{optional_path}/page/{template_path}
- Parameters:
templatePath
- Template path- Returns:
- Resource type path or null if template path did not match expectations
- Given a template path is
-
is
public static boolean is(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull TemplatePathInfo @NotNull ... templates)
Checks if the given page uses a specific template.- Parameters:
page
- AEM pagetemplates
- Template(s)- Returns:
- true if the page uses the template
-
is
public static boolean is(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull java.lang.String @NotNull ... templatePaths)
Checks if the given page uses a specific template.- Parameters:
page
- AEM pagetemplatePaths
- Template path(s)- Returns:
- true if the page uses the template
-
forTemplatePath
@Nullable public static @Nullable TemplatePathInfo forTemplatePath(@NotNull @NotNull java.lang.String templatePath, @NotNull @NotNull TemplatePathInfo @NotNull ... templates)
Lookup a template by the given template path.- Parameters:
templatePath
- Path of templatetemplates
- Templates- Returns:
- The
TemplatePathInfo
instance or null for unknown template paths
-
forTemplatePath
@SafeVarargs @Nullable public static <E extends java.lang.Enum<E> & TemplatePathInfo> @Nullable TemplatePathInfo forTemplatePath(@NotNull @NotNull java.lang.String templatePath, @NotNull @NotNull java.lang.Class<E> @NotNull ... templateEnums)
Lookup a template by the given template path.- Type Parameters:
E
- Template enum- Parameters:
templatePath
- Path of templatetemplateEnums
- Templates- Returns:
- The
TemplatePathInfo
instance or null for unknown template paths
-
forPage
@Nullable public static @Nullable TemplatePathInfo forPage(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull TemplatePathInfo @NotNull ... templates)
Lookup template for given page.- Parameters:
page
- Pagetemplates
- Templates- Returns:
- The
TemplatePathInfo
instance or null for unknown template paths
-
forPage
@SafeVarargs @Nullable public static <E extends java.lang.Enum<E> & TemplatePathInfo> @Nullable TemplatePathInfo forPage(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull java.lang.Class<E> @NotNull ... templateEnums)
Lookup template for given page.- Type Parameters:
E
- Template enum- Parameters:
page
- PagetemplateEnums
- Templates- Returns:
- The
TemplatePathInfo
instance or null for unknown template paths
-
-