use of com.vaadin.flow.server.InvalidRouteLayoutConfigurationException in project flow by vaadin.
the class AbstractRouteRegistryInitializer method checkForConflictingAnnotations.
private void checkForConflictingAnnotations(Class<?> route) {
if (route.isAnnotationPresent(RouteAlias.class) && !route.isAnnotationPresent(Route.class)) {
throw new InvalidRouteLayoutConfigurationException(String.format("'%s'" + " declares '@%s' but doesn't declare '@%s'. " + "The '%s' may not be used without '%s'", route.getCanonicalName(), RouteAlias.class.getSimpleName(), Route.class.getSimpleName(), RouteAlias.class.getSimpleName(), Route.class.getSimpleName()));
}
if (route.isAnnotationPresent(PageTitle.class) && HasDynamicTitle.class.isAssignableFrom(route)) {
throw new DuplicateNavigationTitleException(String.format("'%s' has a PageTitle annotation, but also implements HasDynamicTitle.", route.getName()));
}
/* Validate annotation usage */
Stream.of(AnnotationValidator.class.getAnnotation(HandlesTypes.class).value()).forEach(type -> {
Class<? extends Annotation> annotation = type.asSubclass(Annotation.class);
validateRouteAnnotation(route, annotation);
for (RouteAlias alias : route.getAnnotationsByType(RouteAlias.class)) {
validateRouteAliasAnnotation(route, alias, annotation);
}
});
/* Validate PageConfigurator usage */
validateRouteImplementation(route, PageConfigurator.class);
for (RouteAlias alias : route.getAnnotationsByType(RouteAlias.class)) {
validateRouteAliasImplementation(route, alias, PageConfigurator.class);
}
}
use of com.vaadin.flow.server.InvalidRouteLayoutConfigurationException in project flow by vaadin.
the class AbstractRouteRegistryInitializer method validateRouteAnnotation.
/* Route validator methods for bootstrap annotations */
private void validateRouteAnnotation(Class<?> route, Class<? extends Annotation> annotation) {
Route routeAnnotation = route.getAnnotation(Route.class);
if (!UI.class.equals(routeAnnotation.layout())) {
if (route.isAnnotationPresent(annotation)) {
throw new InvalidRouteLayoutConfigurationException(String.format("%s annotation needs to be on the top parent layout '%s' not on '%s'", annotation.getSimpleName(), RouterUtil.getTopParentLayout(route, routeAnnotation.value()).getName(), route.getName()));
}
List<Class<? extends RouterLayout>> parentLayouts = RouterUtil.getParentLayouts(route, routeAnnotation.value());
Class<? extends RouterLayout> topParentLayout = RouterUtil.getTopParentLayout(route, routeAnnotation.value());
validateParentAnnotation(parentLayouts, topParentLayout, annotation);
}
}
use of com.vaadin.flow.server.InvalidRouteLayoutConfigurationException in project flow by vaadin.
the class AbstractRouteRegistryInitializer method validateRouteImplementation.
/* Route validator methods for bootstrap implementations */
private void validateRouteImplementation(Class<?> route, Class<?> implementation) {
Route annotation = route.getAnnotation(Route.class);
if (!UI.class.equals(annotation.layout())) {
if (implementation.isAssignableFrom(route)) {
throw new InvalidRouteLayoutConfigurationException(String.format("%s needs to be the top parent layout '%s' not '%s'", implementation.getSimpleName(), RouterUtil.getTopParentLayout(route, annotation.value()).getName(), route.getName()));
}
List<Class<? extends RouterLayout>> parentLayouts = RouterUtil.getParentLayouts(route, annotation.value());
Class<? extends RouterLayout> topParentLayout = RouterUtil.getTopParentLayout(route, annotation.value());
validateParentImplementation(parentLayouts, topParentLayout, implementation);
}
}
Aggregations