|
| 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.google.gson.annotations.SerializedName; |
| 10 | +import com.mapbox.api.directions.v5.DirectionsAdapterFactory; |
| 11 | + |
| 12 | +/** |
| 13 | + * Holds information about traffic codes. See {@link Incident#trafficCodes()}. |
| 14 | + */ |
| 15 | +@AutoValue |
| 16 | +public abstract class TrafficCodes extends DirectionsJsonObject { |
| 17 | + |
| 18 | + /** |
| 19 | + * Jartic cause code value. |
| 20 | + * |
| 21 | + * @return jartic code cause code value |
| 22 | + */ |
| 23 | + @Nullable |
| 24 | + @SerializedName("jartic_cause_code") |
| 25 | + public abstract Integer jarticCauseCode(); |
| 26 | + |
| 27 | + /** |
| 28 | + * Jartic regulation code value. |
| 29 | + * |
| 30 | + * @return jartic regulation regulation code value |
| 31 | + */ |
| 32 | + @Nullable |
| 33 | + @SerializedName("jartic_regulation_code") |
| 34 | + public abstract Integer jarticRegulationCode(); |
| 35 | + |
| 36 | + /** |
| 37 | + * Create a new instance of this class by using the {@link Builder} class. |
| 38 | + * |
| 39 | + * @return this class's {@link Builder} for creating a new instance |
| 40 | + */ |
| 41 | + public static Builder builder() { |
| 42 | + return new AutoValue_TrafficCodes.Builder(); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Convert the current {@link TrafficCodes} to its builder holding the currently assigned |
| 47 | + * values. This allows you to modify a single property and then rebuild the object resulting in |
| 48 | + * an updated and modified {@link TrafficCodes}. |
| 49 | + * |
| 50 | + * @return a {@link Builder} with the same values set to match the ones defined in this |
| 51 | + * {@link TrafficCodes} |
| 52 | + */ |
| 53 | + public abstract Builder toBuilder(); |
| 54 | + |
| 55 | + /** |
| 56 | + * Gson type adapter for parsing Gson to this class. |
| 57 | + * |
| 58 | + * @param gson the built {@link Gson} object |
| 59 | + * @return the type adapter for this class |
| 60 | + */ |
| 61 | + public static TypeAdapter<TrafficCodes> typeAdapter(Gson gson) { |
| 62 | + return new AutoValue_TrafficCodes.GsonTypeAdapter(gson); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Create a new instance of this class by passing in a formatted valid JSON String. |
| 67 | + * |
| 68 | + * @param json a formatted valid JSON string defining a TrafficCodes |
| 69 | + * @return a new instance of this class defined by the values passed in the method |
| 70 | + */ |
| 71 | + public static TrafficCodes fromJson(String json) { |
| 72 | + GsonBuilder gson = new GsonBuilder(); |
| 73 | + gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create()); |
| 74 | + return gson.create().fromJson(json, TrafficCodes.class); |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * This builder can be used to set the values describing the {@link TrafficCodes}. |
| 79 | + */ |
| 80 | + @AutoValue.Builder |
| 81 | + public abstract static class Builder extends DirectionsJsonObject.Builder<Builder> { |
| 82 | + |
| 83 | + /** |
| 84 | + * Sets jartic cause code value. |
| 85 | + * |
| 86 | + * @param value jartic cause code value |
| 87 | + */ |
| 88 | + @NonNull |
| 89 | + public abstract Builder jarticCauseCode(@Nullable Integer value); |
| 90 | + |
| 91 | + /** |
| 92 | + * Sets jartic regulation code value. |
| 93 | + * |
| 94 | + * @param value jartic regulation code value |
| 95 | + */ |
| 96 | + @NonNull |
| 97 | + public abstract Builder jarticRegulationCode(@Nullable Integer value); |
| 98 | + |
| 99 | + /** |
| 100 | + * Build a new instance of {@link TrafficCodes}. |
| 101 | + * |
| 102 | + * @return a new instance of {@link TrafficCodes}. |
| 103 | + */ |
| 104 | + @NonNull |
| 105 | + public abstract TrafficCodes build(); |
| 106 | + } |
| 107 | +} |
0 commit comments