Package com.vaadin.flow.router
Record Class RouterState
java.lang.Object
java.lang.Record
com.vaadin.flow.router.RouterState
- Record Components:
location- the location of the current view (path, query parameters, fragment); nevernull. Before the first navigation, this is an empty location (new Location("")).routeParameters- route parameters extracted from the URL; nevernull. May beRouteParameters.empty().activeChain- unmodifiable list of the currently active route target and its parent layouts, leaf first. Nevernull; empty before the first navigation completes.- the class of the leaf route target.nullbefore the first navigation completes.
- All Implemented Interfaces:
Serializable
public record RouterState(Location location, RouteParameters routeParameters, List<HasElement> activeChain, Class<? extends Component> navigationTarget)
extends Record
implements Serializable
An immutable snapshot of a UI's current navigation state.
Carried by UI.routerStateSignal() so that
components can observe the active route reactively, instead of registering an
AfterNavigationListener and manually fetching the initial state on
attach.
The snapshot covers the same data already available through
AfterNavigationEvent plus the navigation target class. It is produced
at the same point that AfterNavigationEvent is dispatched, so the
signal value and the listener notification are always consistent.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRouterState(Location location, RouteParameters routeParameters, List<HasElement> activeChain, Class<? extends Component> navigationTarget) Creates an instance of aRouterStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theactiveChainrecord component.Returns the currently shown leaf view, if any.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.location()Returns the value of thelocationrecord component.Returns the value of thenavigationTargetrecord component.Returns the value of therouteParametersrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RouterState
public RouterState(Location location, RouteParameters routeParameters, List<HasElement> activeChain, Class<? extends Component> navigationTarget) Creates an instance of aRouterStaterecord class.- Parameters:
location- the value for thelocationrecord componentrouteParameters- the value for therouteParametersrecord componentactiveChain- the value for theactiveChainrecord componentnavigationTarget- the value for thenavigationTargetrecord component
-
-
Method Details
-
currentView
Returns the currently shown leaf view, if any.- Returns:
- the leaf route target, or empty if no navigation has happened yet
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
location
Returns the value of thelocationrecord component.- Returns:
- the value of the
locationrecord component
-
routeParameters
Returns the value of therouteParametersrecord component.- Returns:
- the value of the
routeParametersrecord component
-
activeChain
Returns the value of theactiveChainrecord component.- Returns:
- the value of the
activeChainrecord component
-