Trip.Builder


public final class Trip.Builder


A builder of Trip.

Summary

Public constructors

Constructs an empty Builder instance.

Public methods

@NonNull Trip.Builder
addDestination(
    @NonNull Destination destination,
    @NonNull TravelEstimate destinationTravelEstimate
)

Adds a destination to the trip.

@NonNull Trip.Builder
addStep(@NonNull Step step, @NonNull TravelEstimate stepTravelEstimate)

Adds a step to the trip.

@NonNull Trip

Constructs the Trip defined by this builder.

@NonNull Trip.Builder

Sets a description of the current road.

@NonNull Trip.Builder
setLoading(boolean isLoading)

Sets whether the Trip is in a loading state.

Public constructors

Builder

Added in 1.0.0
public Builder()

Constructs an empty Builder instance.

Public methods

addDestination

Added in 1.0.0
public @NonNull Trip.Builder addDestination(
    @NonNull Destination destination,
    @NonNull TravelEstimate destinationTravelEstimate
)

Adds a destination to the trip.

Destinations must be added in order of arrival. A destination is not required. Display surfaces may or may not use the destination and if multiple destinations are added the display may only show information about the first destination.

For every destination added, a corresponding TravelEstimate must be provided. Display surfaces may or may not use the destination travel estimate and if multiple destination travel estimates are added the display may only show information about the first destination travel estimate.

Throws
java.lang.NullPointerException

if step or stepTravelEstimate are null

addStep

Added in 1.0.0
public @NonNull Trip.Builder addStep(@NonNull Step step, @NonNull TravelEstimate stepTravelEstimate)

Adds a step to the trip.

Steps must be added in order of arrival. A step is not required. Display surfaces may or may not use the step and if multiple steps are added the display may only show information about the first step.

For every step added, a corresponding TravelEstimate must be provided. Display surfaces may or may not use the step travel estimate and if multiple step travel estimates are added the display may only show information about the first step travel estimate.

Throws
java.lang.NullPointerException

if step or stepTravelEstimate are null

build

Added in 1.0.0
public @NonNull Trip build()

Constructs the Trip defined by this builder.

setCurrentRoad

Added in 1.0.0
public @NonNull Trip.Builder setCurrentRoad(@NonNull CharSequence currentRoad)

Sets a description of the current road.

Spans are not supported in the input string and will be ignored.

Throws
java.lang.NullPointerException

if currentRoad is null

See also
CarText

setLoading

Added in 1.0.0
public @NonNull Trip.Builder setLoading(boolean isLoading)

Sets whether the Trip is in a loading state.

If set to true, the UI may show a loading indicator, and adding any steps or step travel estimates will throw an IllegalArgumentException.