Class RestPathBuilder<T>
- Type Parameters:
T- resource type
Sub resources could be specified with subResource(String, Class, Object...).
Path parameters and additional query parameters could be resolved with ResourceParamsBuilder.pathParam(String, Object) and
ResourceParamsBuilder.queryParam(String, Object...). Note that when resource path is built from method, required path and
query parameters could be specified as resource methods arguments
(method(ru.vyarus.dropwizard.guice.url.util.Caller)).
Final path could be built either as template (preserving path parameters) ResourceParamsBuilder.buildTemplate() or as
final path with resolved path parameters ResourceParamsBuilder.build().
- Since:
- 26.09.2025
- See Also:
-
Field Summary
Fields inherited from class ru.vyarus.dropwizard.guice.url.resource.ResourceParamsBuilder
builder, pathParams -
Constructor Summary
ConstructorsConstructorDescriptionRestPathBuilder(@Nullable String basePath, Class<T> resource, boolean subResource) Create a builder. -
Method Summary
Modifier and TypeMethodDescriptionAppend resource method path (path fromPathmethod annotation).Append resource method path (path fromPathmethod annotation).Append resource method path (path fromPathmethod annotation).Append provided path to resource path (useful when direct resource method can't be used for construction).<K> RestPathBuilder<K>subResource(String path, Class<K> subResource, Object... args) Append a sub-resource path to the current resource path (with sub-resource method resolution).<K> RestPathBuilder<K>subResource(Caller<T> caller, Class<K> subResource) Append a sub-resource path to the current resource path.Methods inherited from class ru.vyarus.dropwizard.guice.url.resource.ResourceParamsBuilder
applyPath, build, buildTemplate, buildUri, matrixParam, pathParam, queryParam
-
Constructor Details
-
RestPathBuilder
Create a builder.Note that jersey ignores
Pathannotation for sub resources (only lookup method path is used)- Parameters:
basePath- optional base pathresource- target resourcesubResource- true if it is a sub resource (important because@Pathannotation must be ignored)
-
-
Method Details
-
subResource
Append a sub-resource path to the current resource path (with sub-resource method resolution).Sub-resource path is declared by a sub-resource method:
@Path("/sub") SubResource something() {...}. Here sub-resource path would include path from declaration method and path, declared for sub-resource class. The current method does not search for tareget declaration method (in some cases it is impossible), so sub-resource mapping path (from method) must be applied manually.- Type Parameters:
K- sub-resource type- Parameters:
path- sub-resource mapping path (from sub-resource method; could contain String.format() placeholders: %s)subResource- sub-resourceargs- args variables for path placeholders (String.format() arguments)- Returns:
- builder for sub-resource
-
subResource
Append a sub-resource path to the current resource path. Sub resource path is resolved through the called locator method.Note: multiple locator methods could be called at once!
- Type Parameters:
K- sub-resource type- Parameters:
caller- locator method(s) callersubResource- sub-resource type- Returns:
- builder for sub-resource
-
path
Append provided path to resource path (useful when direct resource method can't be used for construction).Query parameters could be specified directly.
- Parameters:
path- target path, relative to resource root (could contain String.format() placeholders: %s)args- variables for path placeholders (String.format() arguments)- Returns:
- parameters builder to specify path and query parameters
- See Also:
-
method
Append resource method path (path fromPathmethod annotation).When parameters are not provided - search for any method with name. If multiple methods with the same name would be found - method with no parameters would be selected, otherwise exception thrown.
- Parameters:
methodName- method nameparameters- method argument types- Returns:
- parameters builder to specify path and query parameters
- Throws:
IllegalStateException- if no unique method found for provided name- See Also:
-
method
Append resource method path (path fromPathmethod annotation).- Parameters:
method- resource method- Returns:
- parameters builder to specify path and query parameters
- See Also:
-
method
Append resource method path (path fromPathmethod annotation). Also, use path and query providers, provided as method arguments. Note that only non-null parameters counted.Might also include sub resource call, if sub resource locator method returns resource instance:
resource.sub(args).method(args)- Parameters:
caller- consumer with exactly one resource method execution- Returns:
- parameters builder to specify path and query parameters
-