com.vaadin.flow.server.startup.

Class RouteTarget

  • All Implemented Interfaces:

    Serializable


    public class RouteTarget
    extends Object
    implements Serializable

    Route target holder that handles getting the correct type of has parameter target.

    Since:

    1.0

    See Also:

    Serialized Form

    • Constructor Detail

      • RouteTarget

        public RouteTarget(Class<? extends Component> target)

        Create a new Route target holder with the given target registered.

        Note! This will create a mutable RouteTarget by default.

        Parameters:

        target - navigation target

        Throws:

        InvalidRouteConfigurationException - exception for miss configured routes where navigation targets can not be clearly selected

      • RouteTarget

        public RouteTarget(Class<? extends Component> target,
                           boolean mutable)

        Create a new Route target holder with the given target registered.

        Parameters:

        target - navigation target

        mutable - if this should be mutable

        Throws:

        InvalidRouteConfigurationException - exception for miss configured routes where navigation targets can not be clearly selected

    • Method Detail

      • addRoute

        public void addRoute(Class<? extends Component> target)

        Add a new route navigation target.

        When adding a new target it will be validated that it is a valid path to add with the already existing navigation targets.

        Parameters:

        target - navigation target to add

        Throws:

        InvalidRouteConfigurationException - exception for miss configured routes where navigation targets can not be clearly selected

      • getTarget

        public Class<? extends Component> getTarget(List<String> segments)

        Get route target for given segments.

        Parameters:

        segments - route segments

        Returns:

        navigation target corresponding to given segments

      • copy

        public RouteTarget copy(boolean mutable)

        Create a copy of this RouteTarget.

        Parameters:

        mutable - if created copy is mutable or not

        Returns:

        copy of this RouteTarget

      • remove

        public void remove(Class<? extends Component> targetRoute)

        Remove target route from this RouteTarget. This will also clear the parent layout chain for the target.

        Parameters:

        targetRoute - route to remove

      • containsTarget

        public boolean containsTarget(Class<? extends Component> target)

        Check if navigation target is present in current target.

        Parameters:

        target - navigation target to check for

        Returns:

        true if navigation target is found in some position

      • isEmpty

        public boolean isEmpty()

        Check if this RouteTarget is empty. This means that it no longer contains any route classes.

        Returns:

        true is no targets are found

      • getRoutes

        public List<Class<? extends Component>> getRoutes()

        Get all registered targets for this routeTarget as a iterable.

        Returns:

        all registered route classes

      • setParentLayouts

        public void setParentLayouts(Class<? extends Component> target,
                                     List<Class<? extends RouterLayout>> parents)

        Set the parent layout chain for target component. This will override any existing parent layout chain for the target.

        Note! if adding parents for a non registered target an IllegalArgumentException will be thrown.

        Parameters:

        target - target to add chain for

        parents - parent layout chain

      • getParentLayouts

        public List<Class<? extends RouterLayout>> getParentLayouts(Class<? extends Component> target)

        Get the parent layout chain defined for the given target.

        Parameters:

        target - target to get parent layout chain for

        Returns:

        parent layout chain