Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
* <p>
* Possible values:
* <ul>
* <li><strong>text (default)</strong>: indicates the text is part of
* the instructions and no other type</li>
* <li><strong>icon</strong>: this is text that can be replaced by an icon, see imageBaseURL</li>
* <li><strong>delimiter</strong>: this is text that can be dropped and
* should be dropped if you are rendering icons</li>
* <li><strong>exit-number</strong>: the exit number for the maneuver</li>
* <li><strong>exit</strong>: the word for exit in the local language</li>
* </ul>
*
* @return String type from above list
* @since 3.0.0
*/
public abstract String type();

/**
* The abbreviated form of text.
* <p>
* 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.
* <p>
* 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
Expand Down Expand Up @@ -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.
* <p>
* Possible values:
* <ul>
* <li><strong>text (default)</strong>: indicates the text is part of the instructions
* and no other type</li>
* <li><strong>icon</strong>: this is text that can be replaced by an icon,
* see imageBaseURL</li>
* <li><strong>delimiter</strong>: this is text that can be dropped and should be dropped
* if you are rendering icons</li>
* <li><strong>exit-number</strong>: the exit number for the maneuver</li>
* <li><strong>exit</strong>: the word for exit in the local language</li>
* </ul>
*
* @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.
* <p>
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
Expand Down