Q - the child class that extends this abstract classR - the type the child class' execute()-function returnspublic abstract class AbstractQuery<Q extends AbstractQuery,R> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
logger
The logger for this object.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractQuery()
Constructor, setting the returnType.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
buildURL()
Generates a String URL based on the supplied values.
|
protected static void |
closeInputStreamQuietly(InputStream stream)
Closes the given InputStream.
|
R |
execute()
Executes this query, returning any result.
|
<T extends R> |
execute(Class<T> type)
Executes this query, returning any result.
|
protected <T extends R> |
makeRequest(String urlStr,
Class<T> type)
Makes a GET request to the NationStates API.
|
protected <T extends R> |
translateResponse(InputStream response,
Class<T> type)
Translates the stream response to the object this Query wishes to return
via its execute() function.
|
protected void |
validateQueryParameters()
Validates the query parameters before executing the query.
|
protected static final Logger logger
protected void validateQueryParameters()
protected String buildURL()
public final R execute()
public <T extends R> T execute(Class<T> type)
T - the type to returntype - the type to returnprotected final <T extends R> T makeRequest(String urlStr, Class<T> type)
T - type to parse tourlStr - the url to make the request totype - type to parse toprotected <T extends R> T translateResponse(InputStream response, Class<T> type)
T - type to parse toresponse - the response to translatetype - type to parse toprotected static final void closeInputStreamQuietly(InputStream stream)
stream - the InputStream to closeCopyright © 2016. All rights reserved.