Skip to content

Commit 10550de

Browse files
author
Pablo Guardiola
authored
add styles api models (#1336)
1 parent 62af3af commit 10550de

8 files changed

Lines changed: 5692 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.mapbox.api.directions.v5.models;
2+
3+
import androidx.annotation.NonNull;
4+
5+
import com.google.auto.value.AutoValue;
6+
import com.google.gson.Gson;
7+
import com.google.gson.TypeAdapter;
8+
9+
import java.io.Serializable;
10+
11+
/**
12+
* ShieldSprite.
13+
*/
14+
@AutoValue
15+
public abstract class ShieldSprite implements Serializable {
16+
17+
/**
18+
* Create a new instance of this class by using the {@link ShieldSprite.Builder} class.
19+
*
20+
* @return {@link ShieldSprite.Builder} for creating a new instance
21+
*/
22+
public static Builder builder() {
23+
return new AutoValue_ShieldSprite.Builder();
24+
}
25+
26+
/**
27+
* Shield sprite's name.
28+
*/
29+
@NonNull
30+
public abstract String spriteName();
31+
32+
/**
33+
* Shield sprite's attributes.
34+
*/
35+
@NonNull
36+
public abstract ShieldSpriteAttribute spriteAttributes();
37+
38+
/**
39+
* Convert the current {@link ShieldSprite} to its builder holding the currently assigned
40+
* values. This allows you to modify a single property and then rebuild the object resulting in
41+
* an updated and modified {@link ShieldSprite}.
42+
*
43+
* @return a {@link ShieldSprite.Builder} with the same values set to match the ones defined
44+
* in this {@link ShieldSprite}
45+
*/
46+
public abstract Builder toBuilder();
47+
48+
/**
49+
* Gson type adapter for parsing Gson to this class.
50+
*
51+
* @param gson the built {@link Gson} object
52+
* @return the type adapter for this class
53+
*/
54+
public static TypeAdapter<ShieldSprite> typeAdapter(Gson gson) {
55+
return new AutoValue_ShieldSprite.GsonTypeAdapter(gson);
56+
}
57+
58+
/**
59+
* This builder can be used to set the values describing the {@link ShieldSprite}.
60+
*/
61+
@AutoValue.Builder
62+
public abstract static class Builder {
63+
64+
/**
65+
* Shield sprite's name.
66+
*
67+
* @param spriteName sprite's name
68+
*/
69+
@NonNull
70+
public abstract Builder spriteName(@NonNull String spriteName);
71+
72+
/**
73+
* Shield sprite's attributes.
74+
*
75+
* @param spriteAttributes sprite's attributes
76+
*/
77+
@NonNull
78+
public abstract Builder spriteAttributes(@NonNull ShieldSpriteAttribute spriteAttributes);
79+
80+
/**
81+
* Build a new {@link ShieldSprite} object.
82+
*
83+
* @return a new {@link ShieldSprite} using the provided values in this builder
84+
*/
85+
@NonNull
86+
public abstract ShieldSprite build();
87+
}
88+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
package com.mapbox.api.directions.v5.models;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.annotation.Nullable;
5+
6+
import com.google.auto.value.AutoValue;
7+
import com.google.gson.Gson;
8+
import com.google.gson.GsonBuilder;
9+
import com.google.gson.TypeAdapter;
10+
import com.mapbox.api.directions.v5.DirectionsAdapterFactory;
11+
12+
import java.io.Serializable;
13+
import java.util.List;
14+
15+
/**
16+
* ShieldSpriteAttribute.
17+
*/
18+
@AutoValue
19+
public abstract class ShieldSpriteAttribute implements Serializable {
20+
21+
/**
22+
* Create a new instance of this class by using the {@link ShieldSpriteAttribute.Builder} class.
23+
*
24+
* @return {@link ShieldSpriteAttribute.Builder} for creating a new instance
25+
*/
26+
public static Builder builder() {
27+
return new AutoValue_ShieldSpriteAttribute.Builder();
28+
}
29+
30+
/**
31+
* Create a new instance of this class by passing in a formatted valid JSON String.
32+
*
33+
* @param json a formatted valid JSON string defining a shield sprite
34+
* @return a new instance of this class defined by the values passed inside this static factory
35+
* method
36+
*/
37+
@NonNull
38+
public static ShieldSpriteAttribute fromJson(@NonNull String json) {
39+
GsonBuilder gson = new GsonBuilder();
40+
gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create());
41+
return gson.create().fromJson(json, ShieldSpriteAttribute.class);
42+
}
43+
44+
/**
45+
* Shield sprite's width.
46+
*/
47+
@NonNull
48+
public abstract Integer width();
49+
50+
/**
51+
* Shield sprite's height.
52+
*/
53+
@NonNull
54+
public abstract Integer height();
55+
56+
/**
57+
* Shield sprite's x position.
58+
*/
59+
@NonNull
60+
public abstract Integer x();
61+
62+
/**
63+
* Shield sprite's y position.
64+
*/
65+
@NonNull
66+
public abstract Integer y();
67+
68+
/**
69+
* Shield sprite's pixel ratio.
70+
*/
71+
@NonNull
72+
public abstract Integer pixelRatio();
73+
74+
/**
75+
* Shield sprite's placeholder (optional).
76+
*/
77+
@Nullable
78+
public abstract List<Double> placeholder();
79+
80+
/**
81+
* Shield sprite's visibility.
82+
*/
83+
@NonNull
84+
public abstract Boolean visible();
85+
86+
/**
87+
* Convert the current {@link ShieldSpriteAttribute} to its builder holding the currently assigned
88+
* values. This allows you to modify a single property and then rebuild the object resulting in
89+
* an updated and modified {@link ShieldSpriteAttribute}.
90+
*
91+
* @return a {@link ShieldSpriteAttribute.Builder} with the same values set to match the ones
92+
* defined in this {@link ShieldSpriteAttribute}
93+
*/
94+
public abstract Builder toBuilder();
95+
96+
/**
97+
* This takes the currently defined values found inside the {@link ShieldSpriteAttribute} instance
98+
* and converts it to a {@link ShieldSpriteAttribute} string.
99+
*
100+
* @return a JSON string which represents a {@link ShieldSpriteAttribute}
101+
*/
102+
@NonNull
103+
public String toJson() {
104+
GsonBuilder gson = new GsonBuilder();
105+
gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create());
106+
return gson.create().toJson(this);
107+
}
108+
109+
/**
110+
* Gson type adapter for parsing Gson to this class.
111+
*
112+
* @param gson the built {@link Gson} object
113+
* @return the type adapter for this class
114+
*/
115+
public static TypeAdapter<ShieldSpriteAttribute> typeAdapter(Gson gson) {
116+
return new AutoValue_ShieldSpriteAttribute.GsonTypeAdapter(gson);
117+
}
118+
119+
/**
120+
* This builder can be used to set the values describing the {@link ShieldSpriteAttribute}.
121+
*/
122+
@AutoValue.Builder
123+
public abstract static class Builder {
124+
125+
/**
126+
* Shield sprite's width.
127+
*
128+
* @param width sprite's width
129+
*/
130+
@NonNull
131+
public abstract Builder width(@NonNull Integer width);
132+
133+
/**
134+
* Shield sprite's height.
135+
*
136+
* @param height sprite's height
137+
*/
138+
@NonNull
139+
public abstract Builder height(@NonNull Integer height);
140+
141+
/**
142+
* Shield sprite's x position.
143+
*
144+
* @param x sprite's x position
145+
*/
146+
@NonNull
147+
public abstract Builder x(@NonNull Integer x);
148+
149+
/**
150+
* Shield sprite's y position.
151+
*
152+
* @param y sprite's x position
153+
*/
154+
@NonNull
155+
public abstract Builder y(@NonNull Integer y);
156+
157+
/**
158+
* Shield sprite's pixel ratio.
159+
*
160+
* @param pixelRatio sprite's pixel ratio
161+
*/
162+
@NonNull
163+
public abstract Builder pixelRatio(@NonNull Integer pixelRatio);
164+
165+
/**
166+
* Shield sprite's placeholder.
167+
*
168+
* @param placeholder sprite's placeholder
169+
*/
170+
@NonNull
171+
public abstract Builder placeholder(@Nullable List<Double> placeholder);
172+
173+
/**
174+
* Shield sprite's visibility.
175+
*
176+
* @param visible sprite's visibility
177+
*/
178+
@NonNull
179+
public abstract Builder visible(@NonNull Boolean visible);
180+
181+
/**
182+
* Build a new {@link ShieldSpriteAttribute} object.
183+
*
184+
* @return a new {@link ShieldSpriteAttribute} using the provided values in this builder
185+
*/
186+
@NonNull
187+
public abstract ShieldSpriteAttribute build();
188+
}
189+
}

0 commit comments

Comments
 (0)