T - the type of the singleton object that is represented by the AbstractRestResourceS - the type of a GetRestObjectEvent that is used to retrieve the singleton objectpublic abstract class AbstractRestResource<T extends AbstractRestObject<T,?>,S extends GetRestObjectEvent<T>> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected com.google.gson.Gson |
gson |
protected T |
restObject |
| Constructor and Description |
|---|
AbstractRestResource()
This constructor constructs and dispatches an instance of the generic GetRestObjectEvent
in order to retrieve the singleton object.
|
AbstractRestResource(com.google.gson.Gson gson)
This constructor constructs and dispatches an instance of the generic GetRestObjectEvent
in order to retrieve the singleton object.
|
| Modifier and Type | Method and Description |
|---|---|
protected <P,R> javax.ws.rs.core.Response |
changeObject(Function<P,R> changeFunction,
String jsonRaw,
Class<P> jsonClass)
Parses the required JSON object from a specified string and calls
a string returning function using the parsed object as argument.
|
protected abstract String |
getAllowedRequests()
This method returns a string that offers a description of viable HTTP requests.
|
javax.ws.rs.core.Response |
getInfoText(javax.ws.rs.core.UriInfo uriInfo)
A HTTP GET request that returns a plain-text representation of the singleton object,
as well as some help text that shows which HTTP requests are possible.
|
protected final T extends AbstractRestObject<T,?> restObject
protected final com.google.gson.Gson gson
public AbstractRestResource(com.google.gson.Gson gson)
gson - a gson instance used to parse JSON requests and responsespublic AbstractRestResource()
@GET
@Produces(value={"text/plain","application/json"})
public javax.ws.rs.core.Response getInfoText(@Context
javax.ws.rs.core.UriInfo uriInfo)
uriInfo - an object that can be used to retrieve the path and possible query parameters.protected abstract String getAllowedRequests()
protected <P,R> javax.ws.rs.core.Response changeObject(Function<P,R> changeFunction, String jsonRaw, Class<P> jsonClass)
P - the target type of the JSON object bodyR - the return type of the changeFunctionchangeFunction - a function that expects a JSON object and returns a stringjsonRaw - the unparsed JSON stringjsonClass - the class that is to be created from the JSON stringCopyright © 2017–2019. All rights reserved.