com.vaadin.flow.server.startup.
Class RouteTarget
- java.lang.Object
-
- com.vaadin.flow.server.startup.RouteTarget
-
All Implemented Interfaces:
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:
-
-
Constructor Summary
Constructors Constructor and Description RouteTarget(Class<? extends Component> target)
Create a new Route target holder with the given target registered.
RouteTarget(Class<? extends Component> target, boolean mutable)
Create a new Route target holder with the given target registered.
-
Method Summary
All Methods Modifier and Type Method and Description void
addRoute(Class<? extends Component> target)
Add a new route navigation target.
boolean
containsTarget(Class<? extends Component> target)
Check if navigation target is present in current target.
RouteTarget
copy(boolean mutable)
Create a copy of this RouteTarget.
List<Class<? extends RouterLayout>>
getParentLayouts(Class<? extends Component> target)
Get the parent layout chain defined for the given target.
List<Class<? extends Component>>
getRoutes()
Get all registered targets for this routeTarget as a iterable.
Class<? extends Component>
getTarget(List<String> segments)
Get route target for given segments.
boolean
isEmpty()
Check if this RouteTarget is empty.
void
remove(Class<? extends Component> targetRoute)
Remove target route from this RouteTarget.
void
setParentLayouts(Class<? extends Component> target, List<Class<? extends RouterLayout>> parents)
Set the parent layout chain for target component.
-
-
-
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 targetThrows:
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 targetmutable
- if this should be mutableThrows:
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 addThrows:
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 segmentsReturns:
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 notReturns:
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 forReturns:
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 forparents
- 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 forReturns:
parent layout chain
-
-