Class ParameterDeserializer

java.lang.Object
com.vaadin.flow.router.ParameterDeserializer

public final class ParameterDeserializer extends Object
Parameter deserialization utility.

For internal use only. May be renamed or removed in a future release.

Since:
1.0
  • Field Details

  • 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 as
      parameter - parameter to deserialize
      targetClass - name of handled class for exception usage
      Returns:
      converted parameter as class if parameterType of supported type
    • deserializeRouteParameters

      public static Object deserializeRouteParameters(Class<?> navigationTarget, List<String> parameters)
      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 parameters
      parameters - the list of route parameters to deserialize
      Returns:
      the deserialized url parameter, can be null
    • validateWildcardType

      public static void validateWildcardType(Class<?> navigationTarget, Class<?> parameterType)
      Validate that we can support the given wildcard parameter type.
      Parameters:
      navigationTarget - navigation target class
      parameterType - parameter type to check validity for usage with wildcard
    • verifyParameters

      public static boolean verifyParameters(Class<?> navigationTarget, List<String> parameters)
      Verifies that the list of route parameters is valid for the given navigation target.
      Parameters:
      navigationTarget - the navigation target to verify against
      parameters - the list of route parameters to verify
      Returns:
      true if the parameters are valid, otherwise false
    • getClassType

      public static Class<?> getClassType(Class<?> navigationTarget)
      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 optional
      parameterAnnotation - annotation to check parameter for
      Returns:
      parameter is optional