Package com.vaadin.flow.router.internal
Class HasUrlParameterFormat
- java.lang.Object
-
- com.vaadin.flow.router.internal.HasUrlParameterFormat
-
- All Implemented Interfaces:
Serializable
public class HasUrlParameterFormat extends Object implements Serializable
Utility methods to transform urls and parameters from/into theHasUrlParameter
format into/from the template format.For internal use only. May be renamed or removed in a future release.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
PARAMETER
Reserved parameter placeholder used when setup internally route path pattern with the parameter design for backward compatibility withHasUrlParameter
.static String
PARAMETER_NAME
Reserved parameter name used when setup internally route path pattern with the parameter design for backward compatibility withHasUrlParameter
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkMandatoryParameter(Class<? extends Component> navigationTarget, RouteParameters parameters)
Verify whether the navigationTarget has mandatory parameter and complies with the given parameter values.static <T> RouteParameters
getParameters(List<T> parametersList)
Transform theHasUrlParameter
values into aRouteParameters
object.static <T> RouteParameters
getParameters(T parameter)
Transform theHasUrlParameter
value into aRouteParameters
object.static List<Class<?>>
getParameterTypes(Collection<String> types)
Gets the types of the parameters from string format.static List<String>
getParameterValues(RouteParameters parameters)
Gets the values for theHasUrlParameter
from the specified route parameters.static String
getTemplate(String urlBase, Class<? extends Component> navigationTarget)
Gets the template for the given url base by appending the parameter according to the given navigationTarget if it's implementingHasUrlParameter
static <T> String
getUrl(String url, List<T> parameters)
Gets the final url by appending the given parameters.static String
getUrlBase(String template)
Gets the url base without the parameter for the given template and navigation target implementing *HasUrlParameter
.
-
-
-
Field Detail
-
PARAMETER_NAME
public static final String PARAMETER_NAME
Reserved parameter name used when setup internally route path pattern with the parameter design for backward compatibility withHasUrlParameter
.- See Also:
- Constant Field Values
-
PARAMETER
public static final String PARAMETER
Reserved parameter placeholder used when setup internally route path pattern with the parameter design for backward compatibility withHasUrlParameter
.- See Also:
- Constant Field Values
-
-
Method Detail
-
getTemplate
public static String getTemplate(String urlBase, Class<? extends Component> navigationTarget)
Gets the template for the given url base by appending the parameter according to the given navigationTarget if it's implementingHasUrlParameter
- Parameters:
urlBase
- url base.navigationTarget
-HasUrlParameter
navigation target.- Returns:
- the final template.
-
getUrlBase
public static String getUrlBase(String template)
Gets the url base without the parameter for the given template and navigation target implementing *HasUrlParameter
.- Parameters:
template
- the template.- Returns:
- the url base excluding the parameter placeholder.
-
getUrl
public static <T> String getUrl(String url, List<T> parameters)
Gets the final url by appending the given parameters.- Type Parameters:
T
- type of the values.- Parameters:
url
- url base.parameters
-HasUrlParameter
parameter values.- Returns:
- navigation url string.
-
getParameters
public static <T> RouteParameters getParameters(T parameter)
Transform theHasUrlParameter
value into aRouteParameters
object.- Type Parameters:
T
- type of the input value.- Parameters:
parameter
- the parameter values.- Returns:
- RouteParameters instance wrapping the given parameter.
-
getParameters
public static <T> RouteParameters getParameters(List<T> parametersList)
Transform theHasUrlParameter
values into aRouteParameters
object.- Type Parameters:
T
- type of the input values.- Parameters:
parametersList
- the list of values.- Returns:
- RouteParameters instance wrapping the given parameters.
-
getParameterValues
public static List<String> getParameterValues(RouteParameters parameters)
Gets the values for theHasUrlParameter
from the specified route parameters.- Parameters:
parameters
- route parameter.- Returns:
- HasUrlParameter compatible values.
-
getParameterTypes
public static List<Class<?>> getParameterTypes(Collection<String> types)
Gets the types of the parameters from string format.- Parameters:
types
- the input string format types.- Returns:
- the class types of the parameters.
-
checkMandatoryParameter
public static void checkMandatoryParameter(Class<? extends Component> navigationTarget, RouteParameters parameters)
Verify whether the navigationTarget has mandatory parameter and complies with the given parameter values.- Parameters:
navigationTarget
- navigation target.parameters
- navigation route parameters.
-
-