Class ParameterBuilder
- java.lang.Object
-
- com.aerisweather.aeris.communication.parameter.ParameterBuilder
-
public class ParameterBuilder extends Object
Parameter builder for increasing ease of adding parameters to anAerisRequest
.
-
-
Constructor Summary
Constructors Constructor Description ParameterBuilder()
Construct an instance of the parameter builder for increasing ease of adding parameters to anAerisRequest
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Parameter[]
build()
Builds the parameters into an array of parameters used to pass into theAerisRequest
.ParameterBuilder
withCustomParameter(String key, String value)
Adds a custom parameter with the given key and value
key=:valueParameterBuilder
withFields(CodedInterface... fields)
Addfields
to the parameterParameterBuilder
withFields(String... fields)
Add afields
parameterParameterBuilder
withFilter(String filter)
Construct afilter
parameter with a string as the value.ParameterBuilder
withFrom(String value)
Constructs thefrom
parameter with the value.
from=:stringParameterBuilder
withLimit(int limit)
Adds alimit
parameter to limit the number of requests.ParameterBuilder
withPlace()
Adds a {PlaceParameter place} parameter by using the IP address for the location.ParameterBuilder
withPlace(double latitude, double longitude)
Adds a {PlaceParameter place} parameter with latitude and longitude coordinatesParameterBuilder
withPlace(double topLat, double leftLon, double botLat, double rightLon)
Adds a {PlaceParameter place} parameter with latitude and longitude coordinates to use with a {EndpointType WITHIN}.ParameterBuilder
withPlace(int fipsCode)
Adds aplace
parameter with a fips code.ParameterBuilder
withPlace(android.content.Context context)
Adds a {PlaceParameter place} parameter and uses the phones location, if available.ParameterBuilder
withPlace(AerisLocation... locs)
Adds a {PlaceParameter place} parameter based on a polygon.ParameterBuilder
withPlace(String value)
Adds a PlaceParameter parameter with a value.ParameterBuilder
withPlace(List<AerisLocation> locs)
Adds a {PlaceParameter place} parameter based on a polygon.ParameterBuilder
withPLimit(int value)
Adds aperiods limit
parameter with number of periods to limit to.ParameterBuilder
withPSort(String value)
Adds aperiod sort
parameter with will sort the periods based on a value.ParameterBuilder
withQuery(String value)
Adds aquery
parameter with the string value.ParameterBuilder
withQuery(String type, String value)
Adds a more advancedquery
parameter with a comparator.ParameterBuilder
withRadius(int distance)
Adds aradius
parameter of a certain distance.ParameterBuilder
withRadius(int distance, RadiusUnit unit)
Adds aradius
parameter of a certain distance.ParameterBuilder
withRadius(String value)
Adds aradius
parameter with the string as the value.ParameterBuilder
withSort(String value)
Adds asort
parameter with the value.ParameterBuilder
withTo(String value)
Adds theto
parameter with the given value.
-
-
-
Constructor Detail
-
ParameterBuilder
public ParameterBuilder()
Construct an instance of the parameter builder for increasing ease of adding parameters to anAerisRequest
.
-
-
Method Detail
-
withFields
public ParameterBuilder withFields(CodedInterface... fields)
Addfields
to the parameter- Parameters:
fields
- array of Coded fields to use.- Returns:
- field parameter with the fields
-
withFields
public ParameterBuilder withFields(String... fields)
Add afields
parameter- Parameters:
fields
- array of String fields to use.- Returns:
- field parameter with the fields
-
withFilter
public ParameterBuilder withFilter(String filter)
Construct afilter
parameter with a string as the value.
filter=:string- Parameters:
filter
- String filter to use.- Returns:
- ParameterBuilder obj
-
withFrom
public ParameterBuilder withFrom(String value)
Constructs thefrom
parameter with the value.
from=:string- Parameters:
value
- value to use- Returns:
- ParameterBuilder obj
-
withPlace
public ParameterBuilder withPlace(String value)
Adds a PlaceParameter parameter with a value. There are many supported values. All spaces are replaces with + signs automatically
City state: seattle,wa | seattle,washington | new+york,new+york
City, state, country: seattle,wa,us | toronto,on,ca
City Country: paris,fr | paris,france
Zip code/postal code: 98109 | 55415 | M3C4H9
3 Char IATA Airport Codes: MSP | ROA
County/parish king+county,wa State-county id: WAC033
NOAA public weather zone: MNZ029- Parameters:
value
- ParameterBuilder obj- Returns:
- ParameterBuilder obj
-
withPlace
public ParameterBuilder withPlace(double latitude, double longitude)
Adds a {PlaceParameter place} parameter with latitude and longitude coordinates- Parameters:
latitude
- doublelongitude
- double- Returns:
- ParameterBuilder obj
-
withPlace
public ParameterBuilder withPlace(double topLat, double leftLon, double botLat, double rightLon)
Adds a {PlaceParameter place} parameter with latitude and longitude coordinates to use with a {EndpointType WITHIN}.- Parameters:
topLat
- doubleleftLon
- doublebotLat
- doublerightLon
- double- Returns:
- ParameterBuilder obj
-
withPlace
public ParameterBuilder withPlace()
Adds a {PlaceParameter place} parameter by using the IP address for the location.- Returns:
- ParameterBuilder obj
-
withPlace
public ParameterBuilder withPlace(android.content.Context context)
Adds a {PlaceParameter place} parameter and uses the phones location, if available. If not, will query location based on the IP.- Parameters:
context
- ParameterBuilder- Returns:
- ParameterBuilder obj
-
withPlace
public ParameterBuilder withPlace(AerisLocation... locs)
Adds a {PlaceParameter place} parameter based on a polygon. Must include at least 3 locations.- Parameters:
locs
- locations to use as a polygon.- Returns:
- ParameterBuilder obj
-
withPlace
public ParameterBuilder withPlace(List<AerisLocation> locs)
Adds a {PlaceParameter place} parameter based on a polygon. Must include at least 3 locations.- Parameters:
locs
- locations to use as a polygon.- Returns:
- ParameterBuilder obj
-
withPlace
public ParameterBuilder withPlace(int fipsCode)
Adds aplace
parameter with a fips code.- Parameters:
fipsCode
- int- Returns:
- ParameterBuilder obj
-
withPLimit
public ParameterBuilder withPLimit(int value)
Adds aperiods limit
parameter with number of periods to limit to.- Parameters:
value
- number of periods to limit to.- Returns:
- ParameterBuilder obj
-
withPSort
public ParameterBuilder withPSort(String value)
Adds aperiod sort
parameter with will sort the periods based on a value.- Parameters:
value
- value to sort by.- Returns:
- ParameterBuilder obj
-
withQuery
public ParameterBuilder withQuery(String value)
Adds aquery
parameter with the string value.
query=:string- Parameters:
value
- value to use.- Returns:
- ParameterBuilder obj
-
withQuery
public ParameterBuilder withQuery(String type, String value)
Adds a more advancedquery
parameter with a comparator.- Parameters:
type
- type to use, often a field namevalue
- value to use as a comparator to the type- Returns:
- ParameterBuilder obj
-
withRadius
public ParameterBuilder withRadius(int distance)
Adds aradius
parameter of a certain distance. Will default to meters.- Parameters:
distance
- distance to use in meters.- Returns:
- ParameterBuilder obj
-
withRadius
public ParameterBuilder withRadius(int distance, RadiusUnit unit)
Adds aradius
parameter of a certain distance.- Parameters:
distance
- distance to use.unit
- unit type to use- Returns:
- ParameterBuilder obj
-
withRadius
public ParameterBuilder withRadius(String value)
Adds aradius
parameter with the string as the value.- Parameters:
value
- value to use- Returns:
- ParameterBuilder obj
-
withSort
public ParameterBuilder withSort(String value)
Adds asort
parameter with the value.- Parameters:
value
- value to use to sort with- Returns:
- ParameterBuilder obj
-
withTo
public ParameterBuilder withTo(String value)
Adds theto
parameter with the given value.- Parameters:
value
- value to use- Returns:
- ParameterBuilder obj
-
withCustomParameter
public ParameterBuilder withCustomParameter(String key, String value)
Adds a custom parameter with the given key and value
key=:value- Parameters:
key
- key to use.value
- value to use.- Returns:
- ParameterBuilder obj
-
withLimit
public ParameterBuilder withLimit(int limit)
Adds alimit
parameter to limit the number of requests. Requests default to limit 1. A maximum of 250 results is enforced.- Parameters:
limit
- Number to limit it to- Returns:
- ParameterBuilder obj
-
build
public Parameter[] build()
Builds the parameters into an array of parameters used to pass into theAerisRequest
.- Returns:
- Parameter array
-
-