From aaffc12e5063797685c425716529b8d8f88ee50b Mon Sep 17 00:00:00 2001 From: danesfeder Date: Wed, 21 Mar 2018 17:57:28 -0400 Subject: [PATCH 1/4] Add Abbreviations and type to BannerComponent --- .../v5/models/BannerComponents.java | 99 ++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) 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..27c4ebb54 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,55 @@ 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 +126,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 From d9f7e96c6ac628fd02503c9ac23c702b82f4bcca Mon Sep 17 00:00:00 2001 From: danesfeder Date: Thu, 22 Mar 2018 14:29:01 -0400 Subject: [PATCH 2/4] Fix checkstyle line length --- .../mapbox/api/directions/v5/models/BannerComponents.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 27c4ebb54..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 @@ -46,9 +46,11 @@ public static Builder builder() { *

* Possible values: *

From a983274331554f9e13a276a94a3167349067e26b Mon Sep 17 00:00:00 2001 From: danesfeder Date: Thu, 22 Mar 2018 15:00:02 -0400 Subject: [PATCH 3/4] Update tests --- .../v5/models/BannerComponentTest.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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..71c841ea7 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,31 @@ 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.builder() + .imageBaseUrl("www.test.com") + .text("test") + .type("icon") + .build(); byte[] serialized = TestUtils.serialize(bannerComponents); assertEquals(bannerComponents, deserialize(serialized, BannerComponents.class)); } From 9b5496a83561ae8af176c0fdf3a8de69947d367e Mon Sep 17 00:00:00 2001 From: danesfeder Date: Thu, 22 Mar 2018 15:09:34 -0400 Subject: [PATCH 4/4] Update component test --- .../mapbox/api/directions/v5/models/BannerComponentTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 71c841ea7..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 @@ -20,8 +20,7 @@ public void sanity() throws Exception { @Test public void testSerializable() throws Exception { - BannerComponents bannerComponents - = BannerComponents.builder() + BannerComponents bannerComponents = BannerComponents.builder() .imageBaseUrl("www.test.com") .text("test") .type("icon")