Search in sources :

Example 1 with RouteAlias

use of com.vaadin.flow.router.RouteAlias 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);
    }
}
Also used : InvalidRouteLayoutConfigurationException(com.vaadin.flow.server.InvalidRouteLayoutConfigurationException) PageTitle(com.vaadin.flow.router.PageTitle) RouteAlias(com.vaadin.flow.router.RouteAlias) HasDynamicTitle(com.vaadin.flow.router.HasDynamicTitle) HandlesTypes(javax.servlet.annotation.HandlesTypes)

Aggregations

HasDynamicTitle (com.vaadin.flow.router.HasDynamicTitle)1 PageTitle (com.vaadin.flow.router.PageTitle)1 RouteAlias (com.vaadin.flow.router.RouteAlias)1 InvalidRouteLayoutConfigurationException (com.vaadin.flow.server.InvalidRouteLayoutConfigurationException)1 HandlesTypes (javax.servlet.annotation.HandlesTypes)1