Class Resource.Builder
java.lang.Object
org.glassfish.jersey.server.model.Resource.Builder
- Enclosing class:
- Resource
Resource model component builder.
-
Method Summary
Modifier and TypeMethodDescriptionaddChildResource
(String relativePath) Add a new child resource to the resource.void
addChildResource
(Resource resource) Add an existing Resource as a child resource of current resource.Add a new arbitrary method model to the resource.Add a new method model to the resource for processing requests of the specified HTTP method.addMethod
(ResourceMethod resourceMethod) Add a new method model that is a copy of the givenresourceMethod
.build()
Build a new resource model.extended
(boolean extended) Set the flag indicating whether the resource is extended or is a core of exposed RESTful API.Merge methods from a given resource model into this resource model builder.mergeWith
(Resource.Builder resourceBuilder) Merge methods from a given resource model builder into this resource model builder.Define a new name of the built resource.Define a new path for the built resource.void
replaceChildResource
(Resource replacedResource, Resource newResource) Replace an existing child resource with a newly supplied one.toString()
updateMethod
(ResourceMethod resourceMethod) Get a method builder for an existing resource method.
-
Method Details
-
name
Define a new name of the built resource. The resource model name is typically used for reporting purposes (e.g. validation etc.).- Parameters:
name
- new name of the resource.- Returns:
- updated builder object.
- See Also:
-
path
Define a new path for the built resource. NOTE: Invoking this method marks a resource as a root resource.- Parameters:
path
- new path for the resource.- Returns:
- updated builder object.
-
addMethod
Add a new method model to the resource for processing requests of the specified HTTP method. The returned builder is automatically bound to the the resource. It is not necessary to invoke thebuild()
method on the method builder after setting all the data. This will be done automatically when the resource is built.- Parameters:
httpMethod
- HTTP method that will be processed by the method.- Returns:
- a new resource method builder.
-
addMethod
Add a new arbitrary method model to the resource. The returned builder is automatically bound to the the resource. It is not necessary to invoke thebuild()
method on the method builder after setting all the data. This will be done automatically when the resource is built.- Returns:
- a new resource method builder.
-
addMethod
Add a new method model that is a copy of the givenresourceMethod
. The returned builder is automatically bound to the the resource. It is not necessary to invoke thebuild()
method on the method builder after setting all the data. This will be done automatically when the resource is built.- Parameters:
resourceMethod
- The resource method based on which the new method builder should be created.- Returns:
- a new resource method builder.
-
updateMethod
Get a method builder for an existing resource method. The original method is removed from the resource and a builder based on it is added.- Parameters:
resourceMethod
- The resource method to be replaced by a builder.- Returns:
- a new resource method builder.
- Throws:
IllegalArgumentException
- in case the method to be updated is not registered in this resource builder.- Since:
- 2.18
-
addChildResource
Add a new child resource to the resource. The returned builder is automatically bound to the the resource. It is not necessary to invoke thebuild()
method on the resource builder after setting all the data. This will be done automatically when the resource is built.- Parameters:
relativePath
- The path of the new child resource relative to this resource.- Returns:
- child resource builder.
- Throws:
IllegalStateException
- in case the child resource for this path exists already.
-
addChildResource
Add an existing Resource as a child resource of current resource.- Parameters:
resource
- Resource to be added as child resource.
-
replaceChildResource
Replace an existing child resource with a newly supplied one.- Parameters:
replacedResource
- old resource to be replaced.newResource
- new resource to add.- Throws:
IllegalArgumentException
- in case there is no such child resource to be replaced.- Since:
- 2.18
-
mergeWith
Merge methods from a given resource model into this resource model builder.- Parameters:
resource
- to be merged into this resource model builder.- Returns:
- updated builder object.
-
extended
Set the flag indicating whether the resource is extended or is a core of exposed RESTful API. The method defines the flag available atResource.isExtended()
.Extended resource model components are helper components that are not considered as a core of a RESTful API. These can be for example
OPTIONS
resource methods
added bymodel processors
orapplication.wadl
resource producing the WADL. Both resource are rather supportive than the core of RESTful API.If not set the resource will not be defined as extended by default.
- Parameters:
extended
- Iftrue
then resource is marked as extended.- Returns:
- updated builder object.
- Since:
- 2.5.1
- See Also:
-
mergeWith
Merge methods from a given resource model builder into this resource model builder.NOTE: Any "open" method builders in the supplied
resourceBuilder
that have not beenexplicitly converted to method models
will be closed as part of this merge operation before merging the resource builder instances.- Parameters:
resourceBuilder
- to be merged into this resource model builder.- Returns:
- updated builder object.
-
build
Build a new resource model.- Returns:
- new (immutable) resource model.
-
toString
-