diff --git a/services-directions/src/main/java/com/mapbox/api/directions/v5/models/BannerComponents.java b/services-directions/src/main/java/com/mapbox/api/directions/v5/models/BannerComponents.java index e1ab6c705..c79753954 100644 --- a/services-directions/src/main/java/com/mapbox/api/directions/v5/models/BannerComponents.java +++ b/services-directions/src/main/java/com/mapbox/api/directions/v5/models/BannerComponents.java @@ -1,6 +1,7 @@ package com.mapbox.api.directions.v5.models; import android.support.annotation.Nullable; + import com.google.auto.value.AutoValue; import com.google.gson.Gson; import com.google.gson.TypeAdapter; @@ -37,9 +38,57 @@ public static Builder builder() { * @return a single snippet of the full text instruction * @since 3.0.0 */ - @Nullable public abstract String text(); + /** + * String giving you more context about the component which may help in visual markup/display + * choices. If the type of the components is unknown it should be treated as text. + *

+ * Possible values: + *

+ * + * @return String type from above list + * @since 3.0.0 + */ + public abstract String type(); + + /** + * The abbreviated form of text. + *

+ * If this is present, there will also be an abbr_priority value. + * + * @return abbreviated form of {@link BannerComponents#text()}. + * @since 3.0.0 + */ + @Nullable + @SerializedName("abbr") + public abstract String abbreviation(); + + /** + * An integer indicating the order in which the abbreviation abbr should be used in + * place of text. The highest priority is 0 and a higher integer value indicates a lower + * priority. There are no gaps in integer values. + *

+ * Multiple components can have the same abbreviationPriority and when this happens all + * components with the same abbr_priority should be abbreviated at the same time. + * Finding no larger values of abbreviationPriority indicates that the string is + * fully abbreviated. + * + * @return Integer indicating the order of the abbreviation + * @since 3.0.0 + */ + @Nullable + @SerializedName("abbr_priority") + public abstract Integer abbreviationPriority(); + /** * In some cases when the {@link LegStep} is a highway or major roadway, there might be a shield * icon that's included to better identify to your user to roadway. Note that this doesn't @@ -79,7 +128,55 @@ public abstract static class Builder { * @return this builder for chaining options together * @since 3.0.0 */ - public abstract Builder text(@Nullable String text); + public abstract Builder text(String text); + + /** + * String giving you more context about the component which may help in visual markup/display + * choices. If the type of the components is unknown it should be treated as text. + *

+ * Possible values: + *

+ * + * @param type String type from above list + * @return this builder for chaining options together + * @since 3.0.0 + */ + public abstract Builder type(String type); + + + /** + * The abbreviated form of text. + * + * @param abbreviation for the given text of this component + * @return this builder for chaining options together + * @since 3.0.0 + */ + public abstract Builder abbreviation(@Nullable String abbreviation); + + /** + * An integer indicating the order in which the abbreviation abbr should be used in + * place of text. The highest priority is 0 and a higher integer value indicates a lower + * priority. There are no gaps in integer values. + *

+ * Multiple components can have the same abbreviationPriority and when this happens all + * components with the same abbr_priority should be abbreviated at the same time. + * Finding no larger values of abbreviationPriority indicates that the string is + * fully abbreviated. + * + * @param abbreviationPriority Integer indicating the order of the abbreviation + * @return this builder for chaining options together + * @since 3.0.0 + */ + public abstract Builder abbreviationPriority(@Nullable Integer abbreviationPriority); /** * In some cases when the {@link LegStep} is a highway or major roadway, there might be a shield diff --git a/services-directions/src/test/java/com/mapbox/api/directions/v5/models/BannerComponentTest.java b/services-directions/src/test/java/com/mapbox/api/directions/v5/models/BannerComponentTest.java index 6ec7fe47e..ee8ea6715 100644 --- a/services-directions/src/test/java/com/mapbox/api/directions/v5/models/BannerComponentTest.java +++ b/services-directions/src/test/java/com/mapbox/api/directions/v5/models/BannerComponentTest.java @@ -1,23 +1,30 @@ package com.mapbox.api.directions.v5.models; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import com.mapbox.core.TestUtils; + import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + public class BannerComponentTest extends TestUtils { @Test public void sanity() throws Exception { - BannerComponents bannerComponents = BannerComponents.builder().text("test").build(); + BannerComponents bannerComponents = BannerComponents.builder() + .text("test") + .type("text") + .build(); assertNotNull(bannerComponents); } @Test public void testSerializable() throws Exception { - BannerComponents bannerComponents - = BannerComponents.builder().imageBaseUrl("www.test.com").text("test").build(); + BannerComponents bannerComponents = BannerComponents.builder() + .imageBaseUrl("www.test.com") + .text("test") + .type("icon") + .build(); byte[] serialized = TestUtils.serialize(bannerComponents); assertEquals(bannerComponents, deserialize(serialized, BannerComponents.class)); }