Search in sources :

Example 1 with HasDynamicTitle

use of com.vaadin.flow.router.HasDynamicTitle 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)

Example 2 with HasDynamicTitle

use of com.vaadin.flow.router.HasDynamicTitle in project flow by vaadin.

the class AbstractRouteRegistryInitializer method checkForConflictingAnnotations.

private void checkForConflictingAnnotations(VaadinContext context, 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 */
    getValidationAnnotations().forEach(type -> {
        Class<? extends Annotation> annotation = type.asSubclass(Annotation.class);
        validateRouteAnnotation(context, route, annotation);
        for (RouteAlias alias : route.getAnnotationsByType(RouteAlias.class)) {
            validateRouteAliasAnnotation(context, route, alias, annotation);
        }
    });
    validateRouteParentLayout(route);
    /* Validate PageConfigurator usage */
    validateRouteImplementation(context, route, PageConfigurator.class);
    for (RouteAlias alias : route.getAnnotationsByType(RouteAlias.class)) {
        validateRouteAliasImplementation(context, 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)

Aggregations

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