Module no.ntnu.principes
Record Class NavigateEvent.NavigationPayload
java.lang.Object
java.lang.Record
no.ntnu.principes.event.navigation.NavigateEvent.NavigationPayload
- Record Components:
route- the target route or identifier for the navigation actiontype- the type of navigation action to perform (e.g., PUSH, REPLACE, POP)params- a map of optional parameters to accompany the navigation action
- Enclosing class:
NavigateEvent
public static record NavigateEvent.NavigationPayload(String route, NavigateEvent.NavigationType type, Map<String,Object> params)
extends Record
Represents the payload for a navigation event, providing details about the navigation
action, target route, and optional parameters for the navigation.
This payload is used to encapsulate data needed for navigation transitions, including:
- The target route or identifier to navigate to
- The type of navigation action to perform (e.g., PUSH, REPLACE, POP)
- Additional parameters as a map of key-value pairs for contextual information
-
Constructor Summary
ConstructorsConstructorDescriptionNavigationPayload(String route, NavigateEvent.NavigationType type, Map<String, Object> params) Creates an instance of aNavigationPayloadrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.<T> Optional<T> Retrieves a parameter from the navigation payload by its key and type if it exists.final inthashCode()Returns a hash code value for this object.params()Returns the value of theparamsrecord component.route()Returns the value of therouterecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
Method Details
-
getParam
Retrieves a parameter from the navigation payload by its key and type if it exists.This method checks if the specified key exists in the parameters map and attempts to cast the value to the specified type. If the key does not exist or the value cannot be cast to the specified type, an empty Optional is returned.
- Type Parameters:
T- the type of the parameter value- Parameters:
key- the key of the parameter to retrievetype- the class type to which the parameter value should be cast- Returns:
- an Optional containing the parameter value if it exists and is of the specified type, or an empty Optional if the key does not exist or the value cannot be cast to the specified type
-
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). -
route
Returns the value of therouterecord component.- Returns:
- the value of the
routerecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
params
Returns the value of theparamsrecord component.- Returns:
- the value of the
paramsrecord component
-