com.jakewharton.pingdom
Class PingdomApiBuilder<T>

java.lang.Object
  extended by com.jakewharton.apibuilder.ApiBuilder
      extended by com.jakewharton.pingdom.PingdomApiBuilder<T>
Type Parameters:
T - Native class type of the HTTP method call result.
Direct Known Subclasses:
ActionsService.GetBuilder, AnalysisService.ListBuilder, CheckService.CreateBuilder, CheckService.DeleteBuilder, CheckService.GetBuilder, CheckService.ListBuilder, ContactService.CreateBuilder, ContactService.DeleteBuilder, ContactService.ListBuilder, ContactService.ModifyBuilder, ProbeService.ListBuilder, ReferenceService.GetBuilder, ReportsEmailService.CreateBuilder, ReportsEmailService.DeleteBuilder, ReportsEmailService.ListBuilder, ReportsEmailService.ModifyBuilder, ReportsPublicService.ActivateBuilder, ReportsPublicService.DeactivateBuilder, ReportsPublicService.ListBuilder, ReportsSharedService.CreateBuilder, ReportsSharedService.DeleteBuilder, ReportsSharedService.GetBuilder, ResultsService.GetBuilder, ServerTimeService.GetBuilder, SettingsService.GetBuilder, SettingsService.ModifyBuilder, SummaryAverageService.GetBuilder, SummaryOutageService.GetBuilder, SummaryPerformanceService.GetBuilder, SummaryProbeService.GetBuilder, TraceRouteService.TraceBuilder

public abstract class PingdomApiBuilder<T>
extends com.jakewharton.apibuilder.ApiBuilder

Pingdom-specific API builder extension which provides helper methods for adding fields, parameters, and post-parameters commonly used in the API.

Author:
Jake Wharton

Nested Class Summary
protected static class PingdomApiBuilder.HttpMethod
          Valid HTTP request methods.
 
Field Summary
 
Fields inherited from class com.jakewharton.apibuilder.ApiBuilder
API_URL_PLACEHOLDER_END, API_URL_PLACEHOLDER_START
 
Constructor Summary
PingdomApiBuilder(PingdomApiService service, com.google.gson.reflect.TypeToken<T> token, String urlFormat)
          Initialize a new builder for an HTTP GET call.
PingdomApiBuilder(PingdomApiService service, com.google.gson.reflect.TypeToken<T> token, String urlFormat, double apiVersion)
          Initalize a new builder for an HTTP GET call with specified API version.
PingdomApiBuilder(PingdomApiService service, com.google.gson.reflect.TypeToken<T> token, String urlFormat, PingdomApiBuilder.HttpMethod method)
          Initialize a new builder for the specified HTTP method call.
PingdomApiBuilder(PingdomApiService service, com.google.gson.reflect.TypeToken<T> token, String urlFormat, PingdomApiBuilder.HttpMethod method, double apiVersion)
          Initialize a new builder for the specified HTTP method and API version.
 
Method Summary
protected  com.google.gson.JsonElement execute()
          Execute the remote API method and return the JSON object result.
protected
<K extends PingdomEnumeration>
com.jakewharton.apibuilder.ApiBuilder
field(String name, K value)
          Add a URL field value.
 T fire()
          Execute remote API method and unmarshall the result to its native type.
protected  com.jakewharton.apibuilder.ApiBuilder parameter(String name, Date value)
          Add a URL parameter value.
protected
<K extends PingdomEnumeration>
com.jakewharton.apibuilder.ApiBuilder
parameter(String name, K value)
          Add a URL parameter value.
protected
<K> com.jakewharton.apibuilder.ApiBuilder
parameter(String name, List<K> valueList)
          Add a URL parameter value.
protected
<K extends PingdomEnumeration>
com.jakewharton.apibuilder.ApiBuilder
parameter(String name, Set<K> valueSet)
          Add a URL parameter value.
protected  PingdomApiBuilder<T> postParameter(String name, boolean value)
          Add a request body parameter value.
protected  PingdomApiBuilder<T> postParameter(String name, int value)
          Add a request body parameter value.
protected
<K extends PingdomEnumeration>
PingdomApiBuilder<T>
postParameter(String name, K value)
          Add a request body parameter value.
protected
<K> PingdomApiBuilder<T>
postParameter(String name, List<K> valueList)
          Add a request body parameter value.
protected  PingdomApiBuilder<T> postParameter(String name, String value)
          Add a request body parameter value.
 
Methods inherited from class com.jakewharton.apibuilder.ApiBuilder
buildUrl, buildUrl, encodeUrl, field, field, field, field, field, hasField, hasParameter, parameter, parameter, parameter, parameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PingdomApiBuilder

public PingdomApiBuilder(PingdomApiService service,
                         com.google.gson.reflect.TypeToken<T> token,
                         String urlFormat)
Initialize a new builder for an HTTP GET call.

Parameters:
service - Service to bind to.
token - Return type token.
urlFormat - URL format string.

PingdomApiBuilder

public PingdomApiBuilder(PingdomApiService service,
                         com.google.gson.reflect.TypeToken<T> token,
                         String urlFormat,
                         PingdomApiBuilder.HttpMethod method)
Initialize a new builder for the specified HTTP method call.

Parameters:
service - Service to bind to.
token - Return type token.
urlFormat - URL format string.
method - HTTP method.

PingdomApiBuilder

public PingdomApiBuilder(PingdomApiService service,
                         com.google.gson.reflect.TypeToken<T> token,
                         String urlFormat,
                         double apiVersion)
Initalize a new builder for an HTTP GET call with specified API version.

Parameters:
service - Service to bind to.
token - Return type token.
urlFormat - URL format string.
apiVersion - API version.

PingdomApiBuilder

public PingdomApiBuilder(PingdomApiService service,
                         com.google.gson.reflect.TypeToken<T> token,
                         String urlFormat,
                         PingdomApiBuilder.HttpMethod method,
                         double apiVersion)
Initialize a new builder for the specified HTTP method and API version.

Parameters:
service - Service to bind to.
token - Return type token.
urlFormat - URL format string.
method - HTTP method.
apiVersion - API version.
Method Detail

fire

public final T fire()
Execute remote API method and unmarshall the result to its native type.

Returns:
Instance of result type.

execute

protected com.google.gson.JsonElement execute()

Execute the remote API method and return the JSON object result.

This method can be overridden to select a specific subset of the JSON object. The overriding implementation should still call 'super.execute()' and then perform the filtering from there.

Returns:
JSON object instance.

parameter

protected com.jakewharton.apibuilder.ApiBuilder parameter(String name,
                                                          Date value)
Add a URL parameter value.

Parameters:
name - Name.
value - Value.
Returns:
Current instance for builder pattern.

parameter

protected <K extends PingdomEnumeration> com.jakewharton.apibuilder.ApiBuilder parameter(String name,
                                                                                         K value)
Add a URL parameter value.

Parameters:
name - Name.
value - Value.
Returns:
Current instance for builder pattern.

parameter

protected <K> com.jakewharton.apibuilder.ApiBuilder parameter(String name,
                                                              List<K> valueList)
Add a URL parameter value.

Parameters:
name - Name.
valueList - List of values.
Returns:
Current instance for builder pattern.

parameter

protected <K extends PingdomEnumeration> com.jakewharton.apibuilder.ApiBuilder parameter(String name,
                                                                                         Set<K> valueSet)
Add a URL parameter value.

Parameters:
name - Name.
valueSet - Set of values.
Returns:
Current instance for builder pattern.

field

protected <K extends PingdomEnumeration> com.jakewharton.apibuilder.ApiBuilder field(String name,
                                                                                     K value)
Add a URL field value.

Parameters:
name - Name.
value - Value.
Returns:
Current instance for builder pattern.

postParameter

protected PingdomApiBuilder<T> postParameter(String name,
                                             String value)
Add a request body parameter value.

Parameters:
name - Name.
value - Value.
Returns:
Current instance for builder pattern.

postParameter

protected PingdomApiBuilder<T> postParameter(String name,
                                             boolean value)
Add a request body parameter value.

Parameters:
name - Name.
value - Value.
Returns:
Current instance for builder pattern.

postParameter

protected PingdomApiBuilder<T> postParameter(String name,
                                             int value)
Add a request body parameter value.

Parameters:
name - Name.
value - Value.
Returns:
Current instance for builder pattern.

postParameter

protected <K> PingdomApiBuilder<T> postParameter(String name,
                                                 List<K> valueList)
Add a request body parameter value.

Parameters:
name - Name.
valueList - List of value.
Returns:
Current instance for builder pattern.

postParameter

protected <K extends PingdomEnumeration> PingdomApiBuilder<T> postParameter(String name,
                                                                            K value)
Add a request body parameter value.

Parameters:
name - Name.
value - Value.
Returns:
Current instance for builder pattern.


Copyright © 2011 Jake Wharton. All Rights Reserved.