Class ResourcePathDeclaration
/users/{userId}
.
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
.
ResourcePathDeclaration
instances must start with the /
character and may contain placeholders denoted by single-mustache syntax.
For example, the ResourcePathDeclaration
/users/{userId}
has a placeholder named userId
.
A ResourcePathDeclaration
is intended for compile-time Resource Method HTTP URL path declarations.
The corresponding runtime type is ResourcePath
and functionality is provided to check if the two "match" via matches(ResourcePath)
.
For example, a ResourcePathDeclaration
/users/{userId}
would match ResourcePath
/users/123
.
Please note the following restrictions on ResourcePathDeclaration
structure:
1. It is not legal to use the same placeholder name more than once in a ResourcePathDeclaration
.
For example:
/users/{userId}
is valid resource path/users/{userId}/roles/{roleId}
is valid resource path/users/{userId}/other/{userId}
is an invalid resource path
/
-delimited path component in which they reside.
For example:
/users/{userId}
is a valid resource path/users/{userId}/details
is a valid resource path/users/prefix{userId}
is an invalid resource path
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents a/
-delimited part of aResourcePathDeclaration
.static enum
How to interpret aResourcePathDeclaration.Component
of aResourcePathDeclaration
- is it literal text or a placeholder? -
Method Summary
Modifier and TypeMethodDescriptionboolean
extractPlaceholders
(ResourcePath resourcePath) What is the mapping between this resource path declaration's placeholder names to the given resource path's placeholder values?What are the/
-delimited components of this resource path declaration?getPath()
What is the string representation of this resource path declaration?int
hashCode()
Is this resource path declaration comprised of all "literal" components (that is, no placeholders)?matches
(ResourcePath resourcePath) Does this resource path declaration match the given resource path (taking placeholders into account, if present)?static ResourcePathDeclaration
Vends an instance that represents a compile-time path declaration, for example/users/{userId}
.toString()
-
Method Details
-
of
Vends an instance that represents a compile-time path declaration, for example/users/{userId}
.- Parameters:
path
- a compile-time path declaration that may include placeholders
-
matches
Does this resource path declaration match the given resource path (taking placeholders into account, if present)?For example, resource path declaration
/users/{userId}
would match/users/123
.- Parameters:
resourcePath
- the resource path against which to match- Returns:
true
if the paths match,false
otherwise
-
extractPlaceholders
What is the mapping between this resource path declaration's placeholder names to the given resource path's placeholder values?For example, placeholder extraction for resource path declaration
/users/{userId}
and resource path/users/123
would result in a value equivalent toMap.of("userId", "123")
.Resource path declaration 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")
.- Parameters:
resourcePath
- runtime version of this resource path declaration, used to provide placeholder values- Returns:
- a mapping of placeholder names to values, or the empty map if there were no placeholders
- Throws:
IllegalArgumentException
- if the provided resource path does not match this resource path declaration, i.e.matches(ResourcePath)
isfalse
-
getPath
-
getComponents
What are the/
-delimited components of this resource path declaration?- Returns:
- the components, or the empty list if this path is equal to
/
-
isLiteral
-
toString
-
equals
-
hashCode
-