Skip to content

Commit a4a6edb

Browse files
committed
add toll costs
1 parent 85f44cd commit a4a6edb

16 files changed

Lines changed: 1165 additions & 2 deletions

File tree

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
package com.mapbox.api.directions.v5.models;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.annotation.Nullable;
5+
import com.google.auto.value.AutoValue;
6+
import com.google.gson.Gson;
7+
import com.google.gson.GsonBuilder;
8+
import com.google.gson.TypeAdapter;
9+
import com.mapbox.api.directions.v5.DirectionsAdapterFactory;
10+
11+
/*
12+
* Payment method for the toll road. See `TollCost`, `PaymentsMethods`.
13+
*/
14+
@AutoValue
15+
@SuppressWarnings({"checkstyle:javadoctype", "checkstyle:javadocmethod"})
16+
public abstract class CostPerVehicleSize extends DirectionsJsonObject {
17+
18+
/*
19+
* Create a new instance of this class by using the `Builder` class.
20+
*
21+
* return this class's `Builder` for creating a new instance
22+
*/
23+
public static Builder builder() {
24+
return new AutoValue_CostPerVehicleSize.Builder();
25+
}
26+
27+
/*
28+
* Returns the toll cost for a small sized vehicle.
29+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
30+
* A toll cost of -1 indicates that the underlying data required
31+
* to compute the toll cost is not available.
32+
*
33+
* return toll cost
34+
*/
35+
@Nullable
36+
public abstract Double small();
37+
38+
/*
39+
* Returns the toll cost for a standard sized vehicle.
40+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
41+
* A toll cost of -1 indicates that the underlying data required
42+
* to compute the toll cost is not available.
43+
*
44+
* return toll cost
45+
*/
46+
@Nullable
47+
public abstract Double standard();
48+
49+
/*
50+
* Returns the toll cost for a middle sized vehicle.
51+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
52+
* A toll cost of -1 indicates that the underlying data required
53+
* to compute the toll cost is not available.
54+
*
55+
* return toll cost
56+
*/
57+
@Nullable
58+
public abstract Double middle();
59+
60+
/*
61+
* Returns the toll cost for a large sized vehicle.
62+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
63+
* A toll cost of -1 indicates that the underlying data required
64+
* to compute the toll cost is not available.
65+
*
66+
* return toll cost
67+
*/
68+
@Nullable
69+
public abstract Double large();
70+
71+
/*
72+
* Returns the toll cost for a jumbo sized vehicle.
73+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
74+
* A toll cost of -1 indicates that the underlying data required
75+
* to compute the toll cost is not available.
76+
*
77+
* return toll cost
78+
*/
79+
@Nullable
80+
public abstract Double jumbo();
81+
82+
/*
83+
* Convert the current `CostPerVehicleSize` to its builder holding the currently assigned
84+
* values. This allows you to modify a single property and then rebuild the object resulting in
85+
* an updated and modified `CostPerVehicleSize`.
86+
*
87+
* return a `Builder` with the same values set to match
88+
* the ones defined in this `CostPerVehicleSize`
89+
*/
90+
public abstract Builder toBuilder();
91+
92+
/*
93+
* Gson type adapter for parsing Gson to this class.
94+
*
95+
* param gson the built `Gson` object
96+
* return the type adapter for this class
97+
*/
98+
public static TypeAdapter<CostPerVehicleSize> typeAdapter(Gson gson) {
99+
return new AutoValue_CostPerVehicleSize.GsonTypeAdapter(gson);
100+
}
101+
102+
/*
103+
* Create a new instance of this class by passing in a formatted valid JSON String.
104+
*
105+
* param json a formatted valid JSON string defining a CostPerVehicleSize
106+
* return a new instance of this class defined by the values passed inside this static factory
107+
* method
108+
*/
109+
public static CostPerVehicleSize fromJson(String json) {
110+
GsonBuilder gson = new GsonBuilder();
111+
gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create());
112+
return gson.create().fromJson(json, CostPerVehicleSize.class);
113+
}
114+
115+
/*
116+
* This builder can be used to set the values describing the `CostPerVehicleSize`.
117+
*/
118+
@AutoValue.Builder
119+
@SuppressWarnings({"checkstyle:javadoctype", "checkstyle:javadocmethod"})
120+
public abstract static class Builder
121+
extends DirectionsJsonObject.Builder<CostPerVehicleSize.Builder> {
122+
123+
/*
124+
* Toll cost for a small sized vehicle.
125+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
126+
* A toll cost of -1 indicates that the underlying data required
127+
* to compute the toll cost is not available.
128+
*
129+
* param small toll cost
130+
* return this builder for chaining options together
131+
*/
132+
@NonNull
133+
public abstract Builder small(@Nullable Double small);
134+
135+
/*
136+
* Toll cost for a standard sized vehicle.
137+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
138+
* A toll cost of -1 indicates that the underlying data required
139+
* to compute the toll cost is not available.
140+
*
141+
* param standard toll cost
142+
* return this builder for chaining options together
143+
*/
144+
@NonNull
145+
public abstract Builder standard(@Nullable Double standard);
146+
147+
/*
148+
* Toll cost for a middle sized vehicle.
149+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
150+
* A toll cost of -1 indicates that the underlying data required
151+
* to compute the toll cost is not available.
152+
*
153+
* param middle toll cost
154+
* return this builder for chaining options together
155+
*/
156+
@NonNull
157+
public abstract Builder middle(@Nullable Double middle);
158+
159+
/*
160+
* Toll cost for a large sized vehicle.
161+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
162+
* A toll cost of -1 indicates that the underlying data required
163+
* to compute the toll cost is not available.
164+
*
165+
* param large toll cost
166+
* return this builder for chaining options together
167+
*/
168+
@NonNull
169+
public abstract Builder large(@Nullable Double large);
170+
171+
/*
172+
* Toll cost for a jumbo sized vehicle.
173+
* A toll cost of 0 is valid and simply means, "no toll costs are incurred for this route".
174+
* A toll cost of -1 indicates that the underlying data required
175+
* to compute the toll cost is not available.
176+
*
177+
* param jumbo toll cost
178+
* return this builder for chaining options together
179+
*/
180+
@NonNull
181+
public abstract Builder jumbo(@Nullable Double jumbo);
182+
183+
/*
184+
* Build a new `CostPerVehicleSize` object.
185+
*
186+
* return a new `CostPerVehicleSize` using the provided values in this builder
187+
*/
188+
@NonNull
189+
public abstract CostPerVehicleSize build();
190+
}
191+
}

services-directions-models/src/main/java/com/mapbox/api/directions/v5/models/DirectionsRoute.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ public static Builder builder() {
142142
@Nullable
143143
public abstract String requestUuid();
144144

145+
/*
146+
* List of calculated toll costs for the route. See `TollCost`.
147+
*
148+
* return list of toll costs
149+
*/
150+
@Nullable
151+
@SerializedName("toll_costs")
152+
@SuppressWarnings("checkstyle:javadocmethod")
153+
public abstract List<TollCost> tollCosts();
154+
145155
/**
146156
* Convert the current {@link DirectionsRoute} to its builder holding the currently assigned
147157
* values. This allows you to modify a single property and then rebuild the object resulting in
@@ -331,6 +341,16 @@ public abstract static class Builder extends DirectionsJsonObject.Builder<Builde
331341
@NonNull
332342
public abstract Builder routeIndex(String routeIndex);
333343

344+
/*
345+
* List of calculated toll costs for the route. See `TollCost`.
346+
*
347+
* param tollCosts list of toll costs
348+
* return this builder for chaining options together
349+
*/
350+
@NonNull
351+
@SuppressWarnings("checkstyle:javadocmethod")
352+
public abstract Builder tollCosts(@Nullable List<TollCost> tollCosts);
353+
334354
/**
335355
* Build a new {@link DirectionsRoute} object.
336356
*
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package com.mapbox.api.directions.v5.models;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.annotation.Nullable;
5+
import com.google.auto.value.AutoValue;
6+
import com.google.gson.Gson;
7+
import com.google.gson.GsonBuilder;
8+
import com.google.gson.TypeAdapter;
9+
import com.mapbox.api.directions.v5.DirectionsAdapterFactory;
10+
11+
/*
12+
* Payment methods for the toll road.
13+
*/
14+
@AutoValue
15+
@SuppressWarnings({"checkstyle:javadoctype", "checkstyle:javadocmethod"})
16+
public abstract class PaymentMethods extends DirectionsJsonObject {
17+
18+
/*
19+
* Create a new instance of this class by using the `Builder` class.
20+
*
21+
* return this class's `Builder` for creating a new instance
22+
*/
23+
public static Builder builder() {
24+
return new AutoValue_PaymentMethods.Builder();
25+
}
26+
27+
/*
28+
* Information about payment by etc.
29+
*
30+
* return etc payment method
31+
*/
32+
@Nullable
33+
public abstract CostPerVehicleSize etc();
34+
35+
/*
36+
* Information about payment by cash.
37+
*
38+
* return cash payment method
39+
*/
40+
@Nullable
41+
public abstract CostPerVehicleSize cash();
42+
43+
/*
44+
* Convert the current `PaymentMethods` to its builder holding the currently assigned
45+
* values. This allows you to modify a single property and then rebuild the object resulting in
46+
* an updated and modified `PaymentMethods`.
47+
*
48+
* return a `Builder` with the same values set to match the ones defined in this `PaymentMethods`
49+
*/
50+
public abstract Builder toBuilder();
51+
52+
/*
53+
* Gson type adapter for parsing Gson to this class.
54+
*
55+
* param gson the built `Gson` object
56+
* return the type adapter for this class
57+
*/
58+
public static TypeAdapter<PaymentMethods> typeAdapter(Gson gson) {
59+
return new AutoValue_PaymentMethods.GsonTypeAdapter(gson);
60+
}
61+
62+
/*
63+
* Create a new instance of this class by passing in a formatted valid JSON String.
64+
*
65+
* param json a formatted valid JSON string defining a PaymentMethods
66+
* return a new instance of this class defined by the values passed inside this static factory
67+
* method
68+
*/
69+
public static PaymentMethods fromJson(String json) {
70+
GsonBuilder gson = new GsonBuilder();
71+
gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create());
72+
return gson.create().fromJson(json, PaymentMethods.class);
73+
}
74+
75+
/*
76+
* This builder can be used to set the values describing the `PaymentMethods`.
77+
*/
78+
@AutoValue.Builder
79+
@SuppressWarnings({"checkstyle:javadoctype", "checkstyle:javadocmethod"})
80+
public abstract static class Builder
81+
extends DirectionsJsonObject.Builder<PaymentMethods.Builder> {
82+
83+
/*
84+
* Information about payment by etc.
85+
*
86+
* param etc payment method
87+
* return this builder for chaining options together
88+
*/
89+
@NonNull
90+
public abstract Builder etc(@Nullable CostPerVehicleSize etc);
91+
92+
/*
93+
* Information about payment by cash.
94+
*
95+
* param cash payment method
96+
* return this builder for chaining options together
97+
*/
98+
@NonNull
99+
public abstract Builder cash(@Nullable CostPerVehicleSize cash);
100+
101+
/*
102+
* Build a new `PaymentMethods` object.
103+
*
104+
* return a new `PaymentMethods` using the provided values in this builder
105+
*/
106+
@NonNull
107+
public abstract PaymentMethods build();
108+
}
109+
}

services-directions-models/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,17 @@ public List<Boolean> snappingIncludeStaticClosuresList() {
876876
@Nullable
877877
public abstract Boolean enableRefresh();
878878

879+
/*
880+
* Whether to return calculated toll cost for the route, if data is available.
881+
* If null, default is false.
882+
*
883+
* return true if the request includes toll cost
884+
*/
885+
@SerializedName("compute_toll_cost")
886+
@Nullable
887+
@SuppressWarnings("checkstyle:javadocmethod")
888+
public abstract Boolean computeTollCost();
889+
879890
/**
880891
* Whether the response should contain metadata holding versioning information.
881892
* <p>
@@ -1019,6 +1030,7 @@ public URL toUrl(@NonNull String accessToken) {
10191030
appendQueryParameter(sb, "max_height", maxHeight());
10201031
appendQueryParameter(sb, "max_width", maxWidth());
10211032
appendQueryParameter(sb, "max_weight", maxWeight());
1033+
appendQueryParameter(sb, "compute_toll_cost", computeTollCost());
10221034
appendQueryParameter(sb, "metadata", metadata());
10231035

10241036
Map<String, SerializableJsonElement> unrecognized = unrecognized();
@@ -2008,6 +2020,17 @@ public Builder snappingIncludeStaticClosuresList(
20082020
@NonNull
20092021
public abstract Builder enableRefresh(@Nullable Boolean enableRefresh);
20102022

2023+
/*
2024+
* Whether to return calculated toll cost for the route, if data is available.
2025+
* Default is false.
2026+
*
2027+
* param computeTollCost whether computed toll cost should be requested
2028+
* return this builder
2029+
*/
2030+
@NonNull
2031+
@SuppressWarnings("checkstyle:javadocmethod")
2032+
public abstract Builder computeTollCost(@Nullable Boolean computeTollCost);
2033+
20112034
/**
20122035
* Whether the response should contain metadata holding versioning information.
20132036
* <p>

0 commit comments

Comments
 (0)