TypedRest for Java
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
net.typedrest.AbstractCollectionEndpoint< TEntity, TElementEndpoint extends Endpoint > Class Template Referenceabstract

Base class for building REST endpoints that represents a collection of TEntitys as TElementEndpoints. More...

Inheritance diagram for net.typedrest.AbstractCollectionEndpoint< TEntity, TElementEndpoint extends Endpoint >:
net.typedrest.AbstractETagEndpoint net.typedrest.GenericCollectionEndpoint< TEntity, TElementEndpoint > net.typedrest.AbstractEndpoint net.typedrest.Endpoint

Public Member Functions

TElementEndpoint get (String id)
 
TElementEndpoint get (TEntity entity)
 
Optional< Boolean > isReadAllAllowed ()
 
List< TEntity > readAll () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 
Optional< Boolean > isReadRangeAllowed ()
 
PartialResponse< TEntity > readRange (Long from, Long to) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 
Optional< Boolean > isCreateAllowed ()
 
TElementEndpoint create (TEntity entity) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 
Optional< Boolean > isCreateAllAllowed ()
 
void createAll (Iterable< TEntity > entities) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 
Optional< Boolean > isSetAllAllowed ()
 
void setAll (Collection< TEntity > entities) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 
- 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.GenericCollectionEndpoint< TEntity, TElementEndpoint >
Class< TEntity > getEntityType ()
 Returns the type of entity the endpoint represents. More...
 
TElementEndpoint get (String id)
 Returns a ElementEndpoint for a specific child element of this collection. More...
 
TElementEndpoint get (TEntity entity)
 Returns a ElementEndpoint for a specific child element of this collection. More...
 
Optional< Boolean > isReadAllAllowed ()
 Shows whether the server has indicated that readAll() is currently allowed. More...
 
List< TEntity > readAll () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Returns all TEntitys. More...
 
Optional< Boolean > isReadRangeAllowed ()
 Shows whether the server has indicated that readRange(Long,Long) is allowed. More...
 
PartialResponse< TEntity > readRange (Long from, Long to) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Returns all TElementEndpoints within a specific range of the set. More...
 
Optional< Boolean > isCreateAllowed ()
 Shows whether the server has indicated that create(java.lang.Object) is currently allowed. More...
 
TElementEndpoint create (TEntity entity) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Creates a new TEntity. More...
 
Optional< Boolean > isCreateAllAllowed ()
 Shows whether the server has indicated that createAll(java.lang.Iterable) is currently allowed. More...
 
void createAll (Iterable< TEntity > entities) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Creates multiple new TEntitys. More...
 
Optional< Boolean > isSetAllAllowed ()
 Shows whether the server has indicated that setAll(java.util.Collection) is currently allowed. More...
 
void setAll (Collection< TEntity > entities) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Replaces the entire content of the collection with new TEntitys. More...
 

Protected Member Functions

 AbstractCollectionEndpoint (Endpoint referrer, URI relativeUri, Class< TEntity > entityType)
 Creates a new paged collection endpoint. More...
 
 AbstractCollectionEndpoint (Endpoint referrer, String relativeUri, Class< TEntity > entityType)
 Creates a new paged collection endpoint. More...
 
abstract TElementEndpoint buildElementEndpoint (URI relativeUri)
 Builds a ElementEndpoint for a specific child element of this collection. More...
 
void handleCapabilities (HttpResponse response)
 
- 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...
 

Protected Attributes

final Class< TEntity > entityType
 
- 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

Base class for building REST endpoints that represents a collection of TEntitys as TElementEndpoints.

Parameters
<TEntity>The type of entity the endpoint represents.
<TElementEndpoint>The specific type of ElementEndpoint to provide for individual TEntitys.

Constructor & Destructor Documentation

◆ AbstractCollectionEndpoint() [1/2]

net.typedrest.AbstractCollectionEndpoint< TEntity, TElementEndpoint extends Endpoint >.AbstractCollectionEndpoint ( Endpoint  referrer,
URI  relativeUri,
Class< TEntity >  entityType 
)
protected

Creates a new paged collection endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer's. Missing trailing slash will be appended automatically.
entityTypeThe type of entity the endpoint represents.

◆ AbstractCollectionEndpoint() [2/2]

net.typedrest.AbstractCollectionEndpoint< TEntity, TElementEndpoint extends Endpoint >.AbstractCollectionEndpoint ( Endpoint  referrer,
String  relativeUri,
Class< TEntity >  entityType 
)
protected

Creates a new paged collection endpoint.

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

Member Function Documentation

◆ buildElementEndpoint()

abstract TElementEndpoint net.typedrest.AbstractCollectionEndpoint< TEntity, TElementEndpoint extends Endpoint >.buildElementEndpoint ( URI  relativeUri)
abstractprotected

Builds a ElementEndpoint for a specific child element of this collection.

Does not perform any network traffic yet.

Parameters
relativeUriThe URI of the child endpoint relative to the this endpoint.
Returns
An ElementEndpoint for a specific element of this collection.

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