com.vaadin.flow.router.Route Java Examples

The following examples show how to use com.vaadin.flow.router.Route. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteUtilTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void renamedRouteAnnotatedClass_updateRouteRegistry_routeIsUpdatedInRegistry() {
    // given
    @Route("aa")
    class A extends Component {
    }
    ApplicationRouteRegistry registry = ApplicationRouteRegistry
            .getInstance(new MockVaadinServletService().getContext());
    registry.setRoute("a", A.class, Collections.emptyList());
    Assert.assertTrue(registry.getConfiguration().hasRoute("a"));

    // when
    RouteUtil.updateRouteRegistry(registry, Collections.emptySet(),
            Collections.singleton(A.class), Collections.emptySet());

    // then
    Assert.assertFalse(registry.getConfiguration().hasRoute("a"));
    Assert.assertTrue(registry.getConfiguration().hasRoute("aa"));
}
 
Example #2
Source File: RouteUtilTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void deletedRouteAnnotatedClass_updateRouteRegistry_routeIsRemovedFromRegistry() {
    // given
    @Route("a")
    class A extends Component {
    }
    ApplicationRouteRegistry registry = ApplicationRouteRegistry
            .getInstance(new MockVaadinServletService().getContext());
    registry.setRoute("a", A.class, Collections.emptyList());
    Assert.assertTrue(registry.getConfiguration().hasRoute("a"));

    // when
    RouteUtil.updateRouteRegistry(registry, Collections.emptySet(),
            Collections.emptySet(), Collections.singleton(A.class));

    // then
    Assert.assertFalse(registry.getConfiguration().hasRoute("a"));
}
 
Example #3
Source File: RouteUtilTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void newRouteAnnotatedClass_updateRouteRegistry_routeIsAddedToRegistry() {
    // given
    @Route("a")
    class A extends Component {
    }
    ApplicationRouteRegistry registry = ApplicationRouteRegistry
            .getInstance(new MockVaadinServletService().getContext());

    // when
    RouteUtil.updateRouteRegistry(registry, Collections.singleton(A.class),
            Collections.emptySet(), Collections.emptySet());

    // then
    Assert.assertTrue(registry.getConfiguration().hasRoute("a"));
}
 
Example #4
Source File: AbstractRouteRegistryInitializer.java    From flow with Apache License 2.0 6 votes vote down vote up
private void validateRouteImplementation(Class<?> route,
        Class<?> implementation) {
    Route annotation = route.getAnnotation(Route.class);
    if (annotation != null && !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(),
                            RouteUtil.getTopParentLayout(route,
                                    RouteUtil.resolve(route, annotation))
                                    .getName(),
                            route.getName()));
        }

        List<Class<? extends RouterLayout>> parentLayouts = RouteUtil
                .getParentLayouts(route,
                        RouteUtil.resolve(route, annotation));
        Class<? extends RouterLayout> topParentLayout = RouteUtil
                .getTopParentLayout(route,
                        RouteUtil.resolve(route, annotation));

        validateParentImplementation(parentLayouts, topParentLayout,
                implementation);
    }
}
 
Example #5
Source File: AbstractRouteRegistryInitializer.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Validate PWA annotations of the potential route classes stream, search
 * for properly annotated PWA class and return it, or null if none existing.
 *
 * @param routeClasses
 *            potential route classes
 * @return a PWA -annotated class, or null if none exist.
 */
@SuppressWarnings("unchecked")
protected Class<?> validatePwaClass(Stream<Class<?>> routeClasses) {
    pwaClass = null;
    routeClasses.forEach(route -> {
        // check and validate route pwa annotation
        validatePwa(route);

        Route routeAnnotation = route.getAnnotation(Route.class);

        if (!UI.class.equals(routeAnnotation.layout())) {
            Class<? extends RouterLayout> topParentLayout = RouteUtil
                    .getTopParentLayout(route,
                            RouteUtil.resolve(route, routeAnnotation));
            // check and validate top parent layout pwa annotation
            validatePwa(topParentLayout);
        }
    });
    return pwaClass;
}
 
Example #6
Source File: RouteUtil.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Get parent layouts for navigation target according to the {@link Route}
 * or {@link RouteAlias} annotation.
 *
 * @param component
 *            navigation target to get parents for
 * @param path
 *            path used to get navigation target so we know which annotation
 *            to handle
 * @return parent layouts for target
 */
public static List<Class<? extends RouterLayout>> getParentLayouts(
        Class<?> component, String path) {
    final List<Class<? extends RouterLayout>> list = new ArrayList<>();

    Optional<Route> route = AnnotationReader.getAnnotationFor(component,
            Route.class);
    List<RouteAlias> routeAliases = AnnotationReader
            .getAnnotationsFor(component, RouteAlias.class);
    if (route.isPresent()
            && path.equals(getRoutePath(component, route.get()))
            && !route.get().layout().equals(UI.class)) {
        list.addAll(collectRouteParentLayouts(route.get().layout()));
    } else {

        Optional<RouteAlias> matchingRoute = getMatchingRouteAlias(
                component, path, routeAliases);
        if (matchingRoute.isPresent()) {
            list.addAll(collectRouteParentLayouts(
                    matchingRoute.get().layout()));
        }
    }

    return list;
}
 
Example #7
Source File: RouteUtil.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the effective route path value of the annotated class.
 *
 * @param component
 *            the component where the route points to
 * @param route
 *            the annotation
 * @return The value of the annotation or naming convention based value if
 *         no explicit value is given.
 */
public static String resolve(Class<?> component, Route route) {
    if (route.value().equals(Route.NAMING_CONVENTION)) {
        String simpleName = component.getSimpleName();
        if ("MainView".equals(simpleName) || "Main".equals(simpleName)) {
            return "";
        }
        if (simpleName.endsWith("View")) {
            return simpleName
                    .substring(0, simpleName.length() - "View".length())
                    .toLowerCase();
        }
        return simpleName.toLowerCase();
    }
    return route.value();
}
 
Example #8
Source File: FrontendDependenciesTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws ClassNotFoundException {
    Mockito.when(classFinder.loadClass(Route.class.getName()))
            .thenReturn((Class) Route.class);

    Mockito.when(classFinder.loadClass(UIInitListener.class.getName()))
            .thenReturn((Class) UIInitListener.class);

    Mockito.when(classFinder
            .loadClass(VaadinServiceInitListener.class.getName()))
            .thenReturn((Class) VaadinServiceInitListener.class);

    Mockito.when(
            classFinder.loadClass(WebComponentExporter.class.getName()))
            .thenReturn((Class) WebComponentExporter.class);

    Mockito.when(classFinder.loadClass(HasErrorParameter.class.getName()))
            .thenReturn((Class) HasErrorParameter.class);

    Mockito.when(classFinder.loadClass(FrontendDependencies.LUMO))
            .thenReturn((Class) FakeLumo.class);

    Mockito.doAnswer(invocation -> {
        return FrontendDependenciesTest.class.getClassLoader()
                .getResource(invocation.getArgumentAt(0, String.class));
    }).when(classFinder).getResource(Mockito.anyString());
}
 
Example #9
Source File: RouteUtilTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void route_path_should_contain_route_and_parent_prefix() {
    String routePath = RouteUtil.getRoutePath(
            RouteWithParentPrefixAndRouteAlias.class,
            RouteWithParentPrefixAndRouteAlias.class
                    .getAnnotation(Route.class));
    Assert.assertEquals(
            "Expected path should only have been parent RoutePrefix",
            "parent/flow", routePath);
}
 
Example #10
Source File: RouteUtilTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void absolute_middle_parent_route_should_not_contain_parent_prefix() {
    String routePath = RouteUtil.getRoutePath(AbsoluteRoute.class,
            AbsoluteCenterRoute.class.getAnnotation(Route.class));
    Assert.assertEquals("No parent prefix should have been added.",
            "absolute/child", routePath);
}
 
Example #11
Source File: RouteUtilTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void absolute_route_should_not_contain_parent_prefix() {
    String routePath = RouteUtil.getRoutePath(AbsoluteRoute.class,
            AbsoluteRoute.class.getAnnotation(Route.class));
    Assert.assertEquals("No parent prefix should have been added.",
            "single", routePath);
}
 
Example #12
Source File: RouteUtilTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void route_path_should_contain_parent_prefix() {
    String routePath = RouteUtil.getRoutePath(
            BaseRouteWithParentPrefixAndRouteAlias.class,
            BaseRouteWithParentPrefixAndRouteAlias.class
                    .getAnnotation(Route.class));
    Assert.assertEquals(
            "Expected path should only have been parent RoutePrefix",
            "parent", routePath);
}
 
Example #13
Source File: DevModeClassFinderTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void applicableClasses_knownClasses() {
    Collection<Class<?>> classes = getApplicableClasses();

    List<Class<?>> knownClasses = Arrays.asList(
        Route.class,
        UIInitListener.class,
        VaadinServiceInitListener.class,
        WebComponentExporter.class,
        WebComponentExporterFactory.class,
        NpmPackage.class,
        NpmPackage.Container.class,
        JsModule.class,
        JsModule.Container.class,
        JavaScript.class,
        JavaScript.Container.class,
        CssImport.class,
        CssImport.Container.class,
        Theme.class,
        NoTheme.class,
        HasErrorParameter.class);

    for (Class<?> clz : classes) {
        assertTrue("should be a known class " + clz.getName(), knownClasses.contains(clz));
    }
    Assert.assertEquals(knownClasses.size(), classes.size());
}
 
Example #14
Source File: ScannerDependenciesTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void should_cacheVisitedClasses() throws Exception {
    FrontendDependencies deps = getFrontendDependencies(
            RoutedClassWithoutAnnotations.class);
    assertEquals(1, deps.getEndPoints().size());
    assertEquals(2, deps.getClasses().size());
    assertTrue(deps.getClasses().contains(Route.class.getName()));
    assertTrue(deps.getClasses()
            .contains(RoutedClassWithoutAnnotations.class.getName()));
}
 
Example #15
Source File: FrontendDependenciesTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void extractsAndScansClassesFromMethodReferences() {
    Mockito.when(classFinder.getAnnotatedClasses(Route.class)).thenReturn(
            Collections.singleton(RouteComponentWithMethodReference.class));

    FrontendDependencies dependencies = new FrontendDependencies(
            classFinder, false);

    List<String> modules = dependencies.getModules();
    Assert.assertEquals(3, modules.size());
    Assert.assertTrue(modules.contains("foo.js"));
    Assert.assertTrue(modules.contains("bar.js"));
    Assert.assertTrue(modules.contains("baz.js"));
}
 
Example #16
Source File: FrontendDependenciesTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void annotationsInRouterLayoutWontBeFlaggedAsBelongingToTheme() {
    Mockito.when(classFinder.getAnnotatedClasses(Route.class)).thenReturn(
            Collections.singleton(RouteComponentWithLayout.class));
    FrontendDependencies dependencies = new FrontendDependencies(
            classFinder, false);

    List<String> expectedOrder = Arrays.asList("theme-foo.js", "foo.js");
    Assert.assertThat("Theme's annotations should come first",
            dependencies.getModules(), is(expectedOrder));
}
 
Example #17
Source File: FrontendDependenciesTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void jsScriptOrderIsPreserved() throws ClassNotFoundException {
    Mockito.when(classFinder.getAnnotatedClasses(Route.class))
            .thenReturn(Collections.singleton(JsOrderComponent.class));
    FrontendDependencies dependencies = new FrontendDependencies(
            classFinder, false);

    Set<String> scripts = dependencies.getScripts();
    Assert.assertEquals(LinkedHashSet.class, scripts.getClass());

    Assert.assertEquals(new ArrayList<>(dependencies.getScripts()),
            Arrays.asList("a.js", "b.js", "c.js"));
}
 
Example #18
Source File: FrontendDependenciesTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void routedComponent_endpointsAreCollected()
        throws ClassNotFoundException {
    Mockito.when(classFinder.getAnnotatedClasses(Route.class))
            .thenReturn(Collections.singleton(RouteComponent.class));
    FrontendDependencies dependencies = new FrontendDependencies(
            classFinder, false);
    List<String> modules = dependencies.getModules();
    Assert.assertEquals(1, modules.size());
    Assert.assertEquals("foo.js", modules.get(0));

    Set<String> scripts = dependencies.getScripts();
    Assert.assertEquals(1, scripts.size());
    Assert.assertEquals("bar.js", scripts.iterator().next());
}
 
Example #19
Source File: RouteUtil.java    From flow with Apache License 2.0 5 votes vote down vote up
/**
 * Get the top most parent layout for navigation target according to the
 * {@link Route} or {@link RouteAlias} annotation. Also handles non route
 * targets with {@link ParentLayout}.
 *
 * @param component
 *            navigation target to get top most parent for
 * @param path
 *            path used to get navigation target so we know which annotation
 *            to handle or null for error views.
 * @return top parent layout for target or null if none found
 */
public static Class<? extends RouterLayout> getTopParentLayout(
        final Class<?> component, final String path) {
    if (path == null) {
        Optional<ParentLayout> parentLayout = AnnotationReader
                .getAnnotationFor(component, ParentLayout.class);
        if (parentLayout.isPresent()) {
            return recurseToTopLayout(parentLayout.get().value());
        }
        // No need to check for Route or RouteAlias as the path is null
        return null;
    }

    Optional<Route> route = AnnotationReader.getAnnotationFor(component,
            Route.class);
    List<RouteAlias> routeAliases = AnnotationReader
            .getAnnotationsFor(component, RouteAlias.class);
    if (route.isPresent()
            && path.equals(getRoutePath(component, route.get()))
            && !route.get().layout().equals(UI.class)) {
        return recurseToTopLayout(route.get().layout());
    } else {
        Optional<RouteAlias> matchingRoute = getMatchingRouteAlias(
                component, path, routeAliases);
        if (matchingRoute.isPresent()) {
            return recurseToTopLayout(matchingRoute.get().layout());
        }
    }

    return null;
}
 
Example #20
Source File: RouterIT.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void routeWithRouteAliasHasNoParents() {
    openRouteUrl(RouterTestServlet.AliasLayout.class
            .getAnnotation(Route.class).value());

    Assert.assertFalse(
            "Found parent layouts even though none should be available.",
            isElementPresent(By.id("mainLayout")));
    Assert.assertFalse(
            "Found parent layouts even though none should be available.",
            isElementPresent(By.id("middleLayout")));
    Assert.assertEquals("Layout content has the wrong class",
            RouterTestServlet.AliasLayout.class.getSimpleName(),
            findElement(By.id("name-div")).getText());
}
 
Example #21
Source File: AbstractRouteRegistryInitializer.java    From flow with Apache License 2.0 5 votes vote down vote up
private void validateRouteAnnotation(Class<?> route,
        Class<? extends Annotation> annotation) {
    Route routeAnnotation = route.getAnnotation(Route.class);
    if (routeAnnotation != null
            && !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(),
                            RouteUtil
                                    .getTopParentLayout(route,
                                            RouteUtil.resolve(route,
                                                    routeAnnotation))
                                    .getName(),
                            route.getName()));
        }

        List<Class<? extends RouterLayout>> parentLayouts = RouteUtil
                .getParentLayouts(route,
                        RouteUtil.resolve(route, routeAnnotation));
        Class<? extends RouterLayout> topParentLayout = RouteUtil
                .getTopParentLayout(route,
                        RouteUtil.resolve(route, routeAnnotation));

        validateParentAnnotation(parentLayouts, topParentLayout,
                annotation);
    }
}
 
Example #22
Source File: AbstractRouteRegistryInitializer.java    From flow with Apache License 2.0 5 votes vote down vote up
private void validateRouteParentLayout(Class<?> route) {
    Route annotation = route.getAnnotation(Route.class);
    ParentLayout parentLayout = route.getAnnotation(ParentLayout.class);
    if (annotation == null || parentLayout == null) {
        return;
    }
    if (!RouterLayout.class.isAssignableFrom(route)) {
        throw new InvalidRouteLayoutConfigurationException(String.format(
                "The class '%s' should either be a '%s' or only a navigation target using"
                        + " '%s.layout' to set the parent layout",
                route.getSimpleName(), RouterLayout.class.getSimpleName(),
                Route.class.getSimpleName()));
    }
}
 
Example #23
Source File: DemoView.java    From flow with Apache License 2.0 5 votes vote down vote up
protected DemoView() {
    Route annotation = getClass().getAnnotation(Route.class);
    if (annotation == null) {
        throw new IllegalStateException(
                getClass().getName() + " should be annotated with @"
                        + Route.class.getName() + " to be a valid view");
    }
    addClassName("demo-view");
    navBar.addClassName("demo-nav");
    add(navBar);
    add(container);

    populateSources();
    initView();
}
 
Example #24
Source File: AbstractAnnotationValidator.java    From flow with Apache License 2.0 5 votes vote down vote up
private List<String> validateAnnotatedClasses(
        Collection<Class<?>> classSet) {
    List<String> offendingAnnotations = new ArrayList<>();

    for (Class<?> clazz : classSet) {
        Route route = clazz.getAnnotation(Route.class);
        if (route != null) {
            if (!UI.class.equals(route.layout())) {
                offendingAnnotations.add(String.format(NON_PARENT,
                        clazz.getName(), getClassAnnotations(clazz)));
            }
            RouteAlias routeAlias = clazz.getAnnotation(RouteAlias.class);
            if (routeAlias != null
                    && !UI.class.equals(routeAlias.layout())) {
                offendingAnnotations.add(String.format(NON_PARENT_ALIAS,
                        clazz.getName(), getClassAnnotations(clazz)));
            }
        } else if (AppShellConfigurator.class.isAssignableFrom(clazz)) {
            // Annotations on the app shell classes are validated in
            // VaadinAppShellInitializer
        } else if (!RouterLayout.class.isAssignableFrom(clazz)) {
            if (!Modifier.isAbstract(clazz.getModifiers())) {
                handleNonRouterLayout(clazz)
                        .ifPresent(offendingAnnotations::add);
            }
        } else if (RouterLayout.class.isAssignableFrom(clazz)
                && clazz.getAnnotation(ParentLayout.class) != null) {
            offendingAnnotations.add(String.format(MIDDLE_ROUTER_LAYOUT,
                    clazz.getName(), getClassAnnotations(clazz)));
        }
    }
    return offendingAnnotations;
}
 
Example #25
Source File: FrontendClassVisitor.java    From flow with Apache License 2.0 5 votes vote down vote up
@Override
public AnnotationVisitor visitAnnotation(String descriptor,
        boolean visible) {
    addSignatureToClasses(children, descriptor);

    // We return different visitor implementations depending on the
    // annotation
    String cname = descriptor.replace("/", ".");
    if (className.equals(endPoint.name)
            && cname.contains(Route.class.getName())) {
        return routeVisitor;
    }
    if (cname.contains(JsModule.class.getName())) {
        return jsModuleVisitor;
    }
    if (cname.contains(JavaScript.class.getName())) {
        return jScriptVisitor;
    }
    if (cname.contains(NoTheme.class.getName())) {
        if (className.equals(endPoint.name)) {
            endPoint.theme.notheme = true;
        }
        return null;
    }
    if (cname.contains(Theme.class.getName())) {
        if (className.equals(endPoint.name)) {
            return themeRouteVisitor;
        }
        if (className.equals(endPoint.layout)) {
            return themeLayoutVisitor;
        }
    }
    if (cname.contains(CssImport.class.getName())) {
        return new CssAnnotationVisitor(endPoint.css);
    }
    // default visitor
    return annotationVisitor;
}
 
Example #26
Source File: DemoView.java    From flow with Apache License 2.0 4 votes vote down vote up
private String getTabUrl(String relativeHref) {
    String href = relativeHref == null || relativeHref.isEmpty() ? ""
            : "/" + relativeHref;
    return getClass().getAnnotation(Route.class).value() + href;
}
 
Example #27
Source File: DefaultNavigationElementInfoProducer.java    From vaadin-app-layout with Apache License 2.0 4 votes vote down vote up
public DefaultNavigationElementInfoProducer() {
    super(info -> info.getAnnotation(Route.class).value());
}
 
Example #28
Source File: FrontendDependencies.java    From flow with Apache License 2.0 4 votes vote down vote up
/**
 * Visits all classes extending
 * {@link com.vaadin.flow.component.WebComponentExporter} or
 * {@link WebComponentExporterFactory} and update an {@link EndPointData}
 * object with the info found.
 *
 * <p>
 * The limitation with {@code WebComponentExporters} is that only one theme
 * can be defined. If the more than one {@code @Theme} annotation is found
 * on the exporters, {@code IllegalStateException} will be thrown. Having
 * {@code @Theme} and {@code @NoTheme} is considered as two theme
 * annotations. However, if no theme is found, {@code Lumo} is used, if
 * available.
 *
 * @param clazz
 *            the exporter endpoint class
 *
 * @throws ClassNotFoundException
 *             if unable to load a class by class name
 * @throws IOException
 *             if unable to scan the class byte code
 */
@SuppressWarnings("unchecked")
private void computeExporterEndpoints(Class<?> clazz)
        throws ClassNotFoundException, IOException {
    // Because of different classLoaders we need compare against class
    // references loaded by the specific class finder loader
    Class<? extends Annotation> routeClass = getFinder()
            .loadClass(Route.class.getName());
    Class<?> exporterClass = getFinder().loadClass(clazz.getName());
    Set<? extends Class<?>> exporterClasses = getFinder()
            .getSubTypesOf(exporterClass);

    // if no exporters in the project, return
    if (exporterClasses.isEmpty()) {
        return;
    }

    HashMap<String, EndPointData> exportedPoints = new HashMap<>();

    for (Class<?> exporter : exporterClasses) {
        String exporterClassName = exporter.getName();
        EndPointData exporterData = new EndPointData(exporter);
        exportedPoints.put(exporterClassName,
                visitClass(exporterClassName, exporterData, false));

        if (!Modifier.isAbstract(exporter.getModifiers())) {
            Class<? extends Component> componentClass = (Class<? extends Component>) ReflectTools
                    .getGenericInterfaceType(exporter, exporterClass);
            if (componentClass != null
                    && !componentClass.isAnnotationPresent(routeClass)) {
                String componentClassName = componentClass.getName();
                EndPointData configurationData = new EndPointData(
                        componentClass);
                exportedPoints.put(componentClassName, visitClass(
                        componentClassName, configurationData, false));
            }
        }
    }

    endPoints.putAll(exportedPoints);
}
 
Example #29
Source File: RouteUtil.java    From flow with Apache License 2.0 3 votes vote down vote up
/**
 * Get the actual route path including all parent layout
 * {@link RoutePrefix}.
 *
 * @param component
 *            navigation target component to get route path for
 * @param route
 *            route annotation to check
 * @return actual path for given route target
 */
public static String getRoutePath(Class<?> component, Route route) {
    if (route.absolute()) {
        return resolve(component, route);
    }
    List<String> parentRoutePrefixes = getRoutePrefixes(component,
            route.layout(), resolve(component, route));
    return parentRoutePrefixes.stream().collect(Collectors.joining("/"));
}
 
Example #30
Source File: AbstractRouteRegistryInitializer.java    From flow with Apache License 2.0 2 votes vote down vote up
/**
 * Any navigation target applicable to be registered on startup should be a
 * {@link Component}, contain the {@link Route} annotation and have
 * {@link Route#registerAtStartup} be {@code true}.
 *
 * @param clazz
 *            class to check for filer
 * @return true if applicable class
 */
private boolean isApplicableClass(Class<?> clazz) {
    return clazz.isAnnotationPresent(Route.class)
            && Component.class.isAssignableFrom(clazz)
            && clazz.getAnnotation(Route.class).registerAtStartup();
}