public abstract static class MapboxMatrix.Builder
extends java.lang.Object
By default, the directions profile is set to driving (without traffic) but can be changed to reflect your users use-case.
Note to contributors: All optional booleans in this builder use the object Boolean
rather than the primitive to allow for unset (null) values.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
abstract MapboxMatrix.Builder |
accessToken(java.lang.String accessToken)
Required to call when this is being built.
|
MapboxMatrix.Builder |
addAnnotations(java.lang.String... annotations)
Optionally pass in annotations to control to change which data to return.
|
MapboxMatrix.Builder |
addApproaches(java.lang.String... approaches)
A semicolon-separated list indicating the side of the road from
which to approach waypoints in a requested route.
|
abstract MapboxMatrix.Builder |
baseUrl(java.lang.String baseUrl)
Optionally change the APIs base URL to something other then the default Mapbox one.
|
MapboxMatrix |
build()
This uses the provided parameters set using the
MapboxMatrix.Builder and first checks that all
values are valid, formats the values as strings for easier consumption by the API, and lastly
creates a new MapboxMatrix object with the values provided. |
abstract MapboxMatrix.Builder |
clientAppName(java.lang.String clientAppName)
Base package name or other simple string identifier.
|
MapboxMatrix.Builder |
coordinate(com.mapbox.geojson.Point coordinate)
This will add a single
Point to the coordinate list which is used to determine the
duration between points. |
MapboxMatrix.Builder |
coordinateListSizeLimit(java.lang.Integer coordinateListSizeLimit)
Override the standard maximum coordinate list size of 25 so that you can
make a Matrix API call with a list of coordinates as large as the value you give to
this method.
|
MapboxMatrix.Builder |
coordinates(java.util.List<com.mapbox.geojson.Point> coordinates)
Add a list of
Point 's which define the points to perform the matrix on. |
MapboxMatrix.Builder |
destinations(java.lang.Integer... destinations)
Optionally pass in indexes to generate an asymmetric matrix.
|
abstract MapboxMatrix.Builder |
profile(java.lang.String profile)
This selects which mode of transportation the user will be using to accurately give the
matrix durations.
|
MapboxMatrix.Builder |
sources(java.lang.Integer... sources)
Optionally pass in indexes to generate an asymmetric matrix.
|
abstract MapboxMatrix.Builder |
user(java.lang.String user)
The username for the account that the directions engine runs on.
|
public abstract MapboxMatrix.Builder user(java.lang.String user)
DirectionsCriteria.PROFILE_DEFAULT_USER
.user
- a non-null string which will replace the default user used in the directions
requestpublic MapboxMatrix.Builder coordinates(java.util.List<com.mapbox.geojson.Point> coordinates)
Point
's which define the points to perform the matrix on. The minimum
points is 2 and the maximum points allowed in totals 25. You can use this method in
conjunction with coordinate(Point)
.coordinates
- a List full of Point
s which define the points to perform the
matrix onpublic MapboxMatrix.Builder coordinate(@NonNull com.mapbox.geojson.Point coordinate)
Point
to the coordinate list which is used to determine the
duration between points. This can be called up to 25 times until you hit the maximum allowed
points. You can use this method in conjunction with coordinates(List)
.coordinate
- a Point
which you'd like the duration between all other pointspublic abstract MapboxMatrix.Builder profile(@NonNull java.lang.String profile)
profile
- required to be one of the String values found in the
DirectionsCriteria.ProfileCriteria
public abstract MapboxMatrix.Builder accessToken(@NonNull java.lang.String accessToken)
ServicesException
will be thrown.accessToken
- Mapbox access token, You must have a Mapbox account inorder to use
the Optimization APIpublic MapboxMatrix.Builder addAnnotations(@Nullable java.lang.String... annotations)
annotations
- 1 or more annotationspublic MapboxMatrix.Builder addApproaches(@Nullable java.lang.String... approaches)
approaches
- null if you'd like the default approaches,
else one of the options found in
DirectionsCriteria.ApproachesCriteria
.public MapboxMatrix.Builder destinations(@Nullable java.lang.Integer... destinations)
destinations
- 1 or more indexes as a integer, if more then one, separate with a commapublic MapboxMatrix.Builder sources(@Nullable java.lang.Integer... sources)
sources
- 1 or more indexes as a integer, if more then one, separate with a commapublic abstract MapboxMatrix.Builder clientAppName(@NonNull java.lang.String clientAppName)
clientAppName
- base package name or other simple string identifierpublic abstract MapboxMatrix.Builder baseUrl(@NonNull java.lang.String baseUrl)
baseUrl
- base url used as end pointpublic MapboxMatrix.Builder coordinateListSizeLimit(@NonNull java.lang.Integer coordinateListSizeLimit)
coordinateListSizeLimit
- the max limit of coordinates used by a single callpublic MapboxMatrix build()
MapboxMatrix.Builder
and first checks that all
values are valid, formats the values as strings for easier consumption by the API, and lastly
creates a new MapboxMatrix
object with the values provided.