Package com.vaadin.flow.router
Class ParameterDeserializer
java.lang.Object
com.vaadin.flow.router.ParameterDeserializer
Parameter deserialization utility.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
deserializeParameter
(Class<T> parameterType, String parameter, String targetClass) Deserializer method for known parameter types.static Object
deserializeRouteParameters
(Class<?> navigationTarget, List<String> parameters) Deserializes the list of url segments to an instance of the parameter type.static Class<?>
getClassType
(Class<?> navigationTarget) Get the parameter type class.static boolean
isAnnotatedParameter
(Class<?> navigationTarget, Class<? extends Annotation> parameterAnnotation) Check if the parameter value is annotated as OptionalParameter.static void
validateWildcardType
(Class<?> navigationTarget, Class<?> parameterType) Validate that we can support the given wildcard parameter type.static boolean
verifyParameters
(Class<?> navigationTarget, List<String> parameters) Verifies that the list of route parameters is valid for the given navigation target.
-
Field Details
-
supportedTypes
Types supported bydeserializeParameter(Class, String, String)
.
-
-
Method Details
-
deserializeParameter
public static <T> T deserializeParameter(Class<T> parameterType, String parameter, String targetClass) Deserializer method for known parameter types.- Type Parameters:
T
- the type to deserialize into- Parameters:
parameterType
- class to deserialize parameter asparameter
- parameter to deserializetargetClass
- name of handled class for exception usage- Returns:
- converted parameter as class if parameterType of supported type
-
deserializeRouteParameters
Deserializes the list of url segments to an instance of the parameter type. Attempts to cast the first parameter segment to the parameter type and returns null if the parameter list is empty.- Parameters:
navigationTarget
- navigation target for which to deserialize parametersparameters
- the list of route parameters to deserialize- Returns:
- the deserialized url parameter, can be
null
-
validateWildcardType
Validate that we can support the given wildcard parameter type.- Parameters:
navigationTarget
- navigation target classparameterType
- parameter type to check validity for usage with wildcard
-
verifyParameters
Verifies that the list of route parameters is valid for the given navigation target.- Parameters:
navigationTarget
- the navigation target to verify againstparameters
- the list of route parameters to verify- Returns:
true
if the parameters are valid, otherwisefalse
-
getClassType
Get the parameter type class.- Parameters:
navigationTarget
- navigation target to get parameter type class for- Returns:
- parameter type class
-
isAnnotatedParameter
public static boolean isAnnotatedParameter(Class<?> navigationTarget, Class<? extends Annotation> parameterAnnotation) Check if the parameter value is annotated as OptionalParameter.- Parameters:
navigationTarget
- navigation target to check for optionalparameterAnnotation
- annotation to check parameter for- Returns:
- parameter is optional
-