use of com.vaadin.flow.component.page.Meta in project flow by vaadin.
the class BootstrapUtils method getMetaTargets.
/**
* Returns the map which contains name and content of the customized meta
* tag for the target route chain that was navigated to, specified with
* {@link Meta} on the {@link Route} class or the {@link ParentLayout} of
* the route.
*
* @param context
* the bootstrap context
* @return the map contains name and content value string for the customized
* meta tag
*/
static Map<String, String> getMetaTargets(BootstrapHandler.BootstrapContext context) {
List<Meta> metaAnnotations = context.getPageConfigurationAnnotations(Meta.class);
boolean illegalValue = false;
Map<String, String> map = new HashMap<>();
for (Meta meta : metaAnnotations) {
if (!meta.name().isEmpty() && !meta.content().isEmpty()) {
map.put(meta.name(), meta.content());
} else {
illegalValue = true;
break;
}
}
if (illegalValue) {
throw new IllegalStateException("Meta tags added via Meta annotation contain null value on name or content attribute.");
}
return map;
}