TypedRest for Java
Public Member Functions | Protected Member Functions | Package Functions | List of all members
net.typedrest.PollingEndpointImpl< TEntity > Class Template Reference

REST endpoint that represents an entity that can be polled for state changes. More...

Inheritance diagram for net.typedrest.PollingEndpointImpl< TEntity >:
net.typedrest.ElementEndpointImpl< TEntity > net.typedrest.PollingEndpoint< TEntity > net.typedrest.AbstractETagEndpoint net.typedrest.ElementEndpoint< TEntity > net.typedrest.ElementEndpoint< TEntity > net.typedrest.AbstractEndpoint net.typedrest.Endpoint net.typedrest.Endpoint net.typedrest.Endpoint

Public Member Functions

 PollingEndpointImpl (Endpoint referrer, URI relativeUri, Class< TEntity > entityType)
 Creates a new polling endpoint. More...
 
 PollingEndpointImpl (Endpoint referrer, URI relativeUri, Class< TEntity > entityType, Predicate< TEntity > endCondition)
 Creates a new polling endpoint. More...
 
 PollingEndpointImpl (Endpoint referrer, String relativeUri, Class< TEntity > entityType)
 Creates a new polling endpoint. More...
 
 PollingEndpointImpl (Endpoint referrer, String relativeUri, Class< TEntity > entityType, Predicate< TEntity > endCondition)
 Creates a new polling endpoint. More...
 
StoppableObservable< TEntity > getObservable ()
 Provides an observable stream of element states. More...
 
- Public Member Functions inherited from net.typedrest.ElementEndpointImpl< TEntity >
 ElementEndpointImpl (Endpoint referrer, URI relativeUri, Class< TEntity > entityType)
 Creates a new element endpoint. More...
 
 ElementEndpointImpl (Endpoint referrer, String relativeUri, Class< TEntity > entityType)
 Creates a new element endpoint. More...
 
TEntity read () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Returns the specific TEntity. More...
 
boolean exists () throws IOException, IllegalAccessException
 Determines whether the entity currently exists. More...
 
Optional< Boolean > isSetAllowed ()
 Shows whether the server has indicated that set(java.lang.Object) is currently allowed. More...
 
TEntity set (TEntity entity) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Sets/replaces the TEntity. More...
 
Optional< Boolean > isMergeAllowed ()
 Shows whether the server has indicated that merge(java.lang.Object) is currently allowed. More...
 
TEntity merge (TEntity entity) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Modifies an existing TEntity by merging changes. More...
 
Optional< Boolean > isDeleteAllowed ()
 Shows whether the server has indicated that delete() is currently allowed. More...
 
void delete () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Deletes the TEntity. More...
 
- Public Member Functions inherited from net.typedrest.AbstractEndpoint
final void setDefaultLink (String rel, String... hrefs)
 Registers one or more default links for a specific relation type. More...
 
final void setDefaultLinkTemplate (String rel, String href)
 Registers a default link template for a specific relation type. More...
 
Set< URI > getLinks (String rel)
 Retrieves all links with a specific relation type cached from the last request. More...
 
Map< URI, String > getLinksWithTitles (String rel)
 Retrieves all links (with titles) with a specific relation type cached from the last request. More...
 
URI link (String rel)
 Retrieves a single link with a specific relation type. More...
 
UriTemplate linkTemplate (String rel)
 Retrieves a link template with a specific relation type. More...
 
String toString ()
 
- Public Member Functions inherited from net.typedrest.Endpoint
URI getUri ()
 The HTTP URI of the remote resource. More...
 
Executor getExecutor ()
 The REST executor used to communicate with the remote resource. More...
 
ObjectMapper getSerializer ()
 Controls the serialization of entities sent to and received from the server. More...
 
default URI linkTemplate (String rel, String variableName, Object value)
 Retrieves a link template with a specific relation type and resolves it. More...
 
- Public Member Functions inherited from net.typedrest.ElementEndpoint< TEntity >
Class< TEntity > getEntityType ()
 Returns the type of entity the endpoint represents. More...
 
default TEntity update (TEntity entity) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Sets/replaces the TEntity. More...
 
default TEntity update (Consumer< TEntity > updateAction) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Reads the current state of the entity, applies a change to it and stores the result. More...
 
default TEntity update (Consumer< TEntity > updateAction, int maxRetries) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Reads the current state of the entity, applies a change to it and stores the result. More...
 
- Public Member Functions inherited from net.typedrest.PollingEndpoint< TEntity >
int getPollingInterval ()
 Gets the interval in which to send requests to the server. More...
 
void setPollingInterval (int interval)
 Sets the interval in which to send requests to the server. More...
 

Protected Member Functions

void handleResponse (HttpResponse response, Request request) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 
- Protected Member Functions inherited from net.typedrest.AbstractETagEndpoint
 AbstractETagEndpoint (Endpoint referrer, URI relativeUri)
 
 AbstractETagEndpoint (Endpoint referrer, String relativeUri)
 
HttpEntity getContent () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Performs an HTTP GET request on the Endpoint#getUri() and caches the response if the server sends an ETag header. More...
 
HttpResponse putContent (HttpEntity content) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Performs an HTTP PUT request on the Endpoint#getUri(). More...
 
HttpResponse deleteContent () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Performs an HTTP DELETE request on the Endpoint#getUri(). More...
 
- Protected Member Functions inherited from net.typedrest.AbstractEndpoint
 AbstractEndpoint (URI uri, Executor executor, ObjectMapper serializer)
 Creates a new REST endpoint with an absolute URI. More...
 
 AbstractEndpoint (Endpoint referrer, URI relativeUri)
 Creates a new REST endpoint with a relative URI. More...
 
 AbstractEndpoint (Endpoint referrer, String relativeUri)
 Creates a new REST endpoint with a relative URI. More...
 
HttpResponse executeAndHandle (Request request) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Executes a REST request and wraps HTTP status codes in appropriate Exception types. More...
 
HttpResponse execute (Request request) throws IOException
 Executes a REST request adding any configured defaultHeaders. More...
 
void handleResponse (HttpResponse response, Request request) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Handles the response of a REST request and wraps HTTP status codes in appropriate Exception types. More...
 
void handleErrors (HttpResponse response, Request request) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Wraps HTTP status codes in appropriate Exception types. More...
 
void handleHeaderLinks (HttpResponse response, Map< String, Map< URI, String >> links, Map< String, String > linkTemplates)
 Handles links embedded in HTTP response headers. More...
 
void handleBodyLinks (JsonNode jsonBody, Map< String, Map< URI, String >> links, Map< String, String > linkTemplates)
 Handles links embedded in JSON response bodies. More...
 
void handleCapabilities (HttpResponse response)
 Handles allowed HTTP methods and other capabilities reported by the server. More...
 
Optional< Boolean > isMethodAllowed (String method)
 Shows whether the server has indicated that a specific HTTP method is currently allowed. More...
 

Package Functions

StoppableObservable< TEntity > getObservable (Scheduler scheduler)
 Provides an observable stream of element states. More...
 

Additional Inherited Members

- Protected Attributes inherited from net.typedrest.AbstractEndpoint
final URI uri
 
final Executor executor
 
final ObjectMapper serializer
 
final Collection< Header > defaultHeaders = new LinkedList<>()
 A set of default HTTP headers to be added to each request.
 

Detailed Description

REST endpoint that represents an entity that can be polled for state changes.

Parameters
<TEntity>The type of entity the endpoint represents.

Constructor & Destructor Documentation

◆ PollingEndpointImpl() [1/4]

net.typedrest.PollingEndpointImpl< TEntity >.PollingEndpointImpl ( Endpoint  referrer,
URI  relativeUri,
Class< TEntity >  entityType 
)

Creates a new polling endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer's.
entityTypeThe type of entity the endpoint represents.

◆ PollingEndpointImpl() [2/4]

net.typedrest.PollingEndpointImpl< TEntity >.PollingEndpointImpl ( Endpoint  referrer,
URI  relativeUri,
Class< TEntity >  entityType,
Predicate< TEntity >  endCondition 
)

Creates a new polling endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer's.
entityTypeThe type of entity the endpoint represents.
endConditionA check to determine whether the entity has reached its final state an no further polling is required.

◆ PollingEndpointImpl() [3/4]

net.typedrest.PollingEndpointImpl< TEntity >.PollingEndpointImpl ( Endpoint  referrer,
String  relativeUri,
Class< TEntity >  entityType 
)

Creates a new polling endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer's. Prefix ./ to append a trailing slash to the referrer URI if missing.
entityTypeThe type of entity the endpoint represents.

◆ PollingEndpointImpl() [4/4]

net.typedrest.PollingEndpointImpl< TEntity >.PollingEndpointImpl ( Endpoint  referrer,
String  relativeUri,
Class< TEntity >  entityType,
Predicate< TEntity >  endCondition 
)

Creates a new polling endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer's. Prefix ./ to append a trailing slash to the referrer URI if missing.
entityTypeThe type of entity the endpoint represents.
endConditionA check to determine whether the entity has reached its final state an no further polling is required.

Member Function Documentation

◆ getObservable() [1/2]

StoppableObservable<TEntity> net.typedrest.PollingEndpointImpl< TEntity >.getObservable ( )

Provides an observable stream of element states.

Compares entities using Object#equals(java.lang.Object) to detect changes.

Returns
An observable stream of element states.

Implements net.typedrest.PollingEndpoint< TEntity >.

◆ getObservable() [2/2]

StoppableObservable<TEntity> net.typedrest.PollingEndpointImpl< TEntity >.getObservable ( Scheduler  scheduler)
package

Provides an observable stream of element states.

Compares entities using Object#equals(java.lang.Object) to detect changes.

Parameters
pollingIntervalThe interval in milliseconds in which to send requests to the server.
endConditionAn optional predicate determining which entity state ends the polling process.
schedulerThe scheduler used to run the background thread.
Returns
An observable stream of element states.

The documentation for this class was generated from the following file: