Package com.sportdataapi.util
Class AbstractClient
java.lang.Object
com.sportdataapi.util.AbstractClient
- Direct Known Subclasses:
BookmakersClient
,CountriesClient
,LeaguesClient
,MarketsClient
,MatchesClient
,OddsClient
,PlayersClient
,RefereesClient
,RoundsClient
,SdaClient
,SeasonsClient
,SoccerClient
,StagesClient
,StandingsClient
,StatusClient
,TeamsClient
,TopScorersClient
,VenuesClient
public abstract class AbstractClient
extends java.lang.Object
Base class for all client instances.
- Author:
- ralph
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractClient(javax.ws.rs.client.WebTarget target)
Constructor. -
Method Summary
Modifier and Type Method Description void
addRequestListener(RequestListener listener)
Adds a request listener.protected void
fireRequestRegistered(java.net.URI uri)
Informs all listeners about the last URI.<T extends AbstractClient>
Tget(java.lang.Class<T> clazz)
Returns the subclient of the given type.java.net.URI
getLastUri()
Returns the last registered URI that was requested (can be null)javax.ws.rs.client.Invocation.Builder
getRequest()
Returns a request builder.protected javax.ws.rs.client.WebTarget
getTarget()
Returns the target.protected javax.ws.rs.client.WebTarget
registerRequest(javax.ws.rs.client.WebTarget target)
Register the target that it is requested now.
-
Constructor Details
-
AbstractClient
protected AbstractClient(javax.ws.rs.client.WebTarget target)Constructor.- Parameters:
target
- - the target to request.
-
-
Method Details
-
registerRequest
protected javax.ws.rs.client.WebTarget registerRequest(javax.ws.rs.client.WebTarget target)Register the target that it is requested now.Descendants shall call this method in order to allow debug of URIs requested.
- Parameters:
target
- - the target to register- Returns:
- the target again (for method chaining)
-
getRequest
public javax.ws.rs.client.Invocation.Builder getRequest()Returns a request builder.- Returns:
- the builder
-
getLastUri
public java.net.URI getLastUri()Returns the last registered URI that was requested (can be null)- Returns:
- the last URI that was requested
-
getTarget
protected javax.ws.rs.client.WebTarget getTarget()Returns the target.- Returns:
- the target
-
addRequestListener
Adds a request listener.- Parameters:
listener
- - listener to add
-
fireRequestRegistered
protected void fireRequestRegistered(java.net.URI uri)Informs all listeners about the last URI.- Parameters:
uri
- - the URI to be fired
-
get
Returns the subclient of the given type.Be aware that subclient use relative REST API paths.
- Type Parameters:
T
- - Class of subclient- Parameters:
clazz
- - class of subclient- Returns:
- new or existing instance of subclient
-