Class ResourcePathDeclaration

java.lang.Object
com.soklet.ResourcePathDeclaration

@ThreadSafe public final class ResourcePathDeclaration extends Object
A compile-time HTTP URL path declaration associated with an annotated Resource Method, such as /users/{userId}.

You may obtain instances via the fromPath(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
2. Placeholders must span the entire /-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

In addition to simple placeholders, this version supports a special "varargs" placeholder indicated by a trailing * in the placeholder name. For example, /static/{filePath*}. When present, the varargs placeholder must appear only once and as the last component in the path. Its name must be non-empty and must not duplicate a simple placeholder name. It matches zero or more path components: /static/{filePath*} matches /static, with filePath mapped to "". The default parameter provider preserves this empty String when using default String conversion. Braces are reserved for placeholders: empty, nested, unbalanced and partial-component placeholders are invalid. The annotation processor uses this same validation and reports invalid declarations on the annotated method.

Author:
Mark Allen