Class ResourcePath
/users/123
.
You may obtain instances via the of(String)
factory method.
Note: this type is not normally used by Soklet applications unless they support Server-Sent Events or choose to implement a custom ResourceMethodResolver
.
The corresponding compile-time type for ResourcePath
is ResourcePathDeclaration
and functionality is provided to check if the two "match" via matches(ResourcePathDeclaration)
.
For example, a ResourcePath
/users/123
would match ResourcePathDeclaration
/users/{userId}
.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionboolean
extractPlaceholders
(ResourcePathDeclaration resourcePathDeclaration) What is the mapping between this resource path's placeholder values to the given resource path declaration's placeholder names?What are the/
-delimited components of this resource path?getPath()
What is the string representation of this resource path?int
hashCode()
matches
(ResourcePathDeclaration resourcePathDeclaration) Does this resource path match the given resource path (taking placeholders/varargs into account, if present)?static ResourcePath
Vends an instance that represents a runtime representation of a resource path, for example/users/123
.toString()
-
Method Details
-
of
Vends an instance that represents a runtime representation of a resource path, for example/users/123
.This is in contrast to
ResourcePathDeclaration
, which represents compile-time path declarations that may include placeholders, e.g./users/{userId}
.- Parameters:
path
- a runtime path (no placeholders) e.g./users/123
-
matches
Does this resource path match the given resource path (taking placeholders/varargs into account, if present)?For example, resource path
/users/123
would match the resource path declaration/users/{userId}
.- Parameters:
resourcePathDeclaration
- the compile-time declaration to match against- Returns:
true
if this resource path matches,false
otherwise
-
extractPlaceholders
@Nonnull public Map<String,String> extractPlaceholders(@Nonnull ResourcePathDeclaration resourcePathDeclaration) What is the mapping between this resource path's placeholder values to the given resource path declaration's placeholder names?For example, placeholder extraction for resource path
/users/123
and resource path declaration/users/{userId}
would result in a value equivalent toMap.of("userId", "123")
.Resource path placeholder values are automatically URL-decoded. For example, placeholder extraction for resource path declaration
/users/{userId}
and resource path/users/ab%20c
would result in a value equivalent toMap.of("userId", "ab c")
.For varargs placeholders, the extra path components are joined with '/'.
- Parameters:
resourcePathDeclaration
- compile-time resource path, used to provide placeholder names- Returns:
- a mapping of placeholder names to values, or the empty map if there were no placeholders
- Throws:
IllegalArgumentException
- if the provided resource path declaration does not match this resource path, i.e.matches(ResourcePathDeclaration)
isfalse
-
getPath
-
getComponents
What are the/
-delimited components of this resource path?- Returns:
- the components, or the empty list if this path is equal to
/
-
toString
-
equals
-
hashCode
-