Skip to content

Commit

Permalink
NetworkProvider: Rename Option to TripFlag.
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Nov 5, 2018
1 parent 0831d0f commit 2e5f16d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion enabler/src/de/schildbach/pte/AbstractEfaProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ else if (options.accessibility == Accessibility.LIMITED)
url.addEncodedQueryParameter("trITMOTvalue100", "10"); // maximum time to walk to first or from last
// stop

if (options.options != null && options.options.contains(Option.BIKE))
if (options.flags != null && options.flags.contains(TripFlag.BIKE))
url.addEncodedQueryParameter("bikeTakeAlong", "1");

url.addEncodedQueryParameter("locationServerActive", "1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ protected final QueryTripsResult queryTripsXml(Location from, @Nullable Location
else
productsStr = allProductsString();

final char bikeChar = (options.options != null && options.options.contains(Option.BIKE)) ? '1' : '0';
final char bikeChar = (options.flags != null && options.flags.contains(TripFlag.BIKE)) ? '1' : '0';

final StringBuilder conReq = new StringBuilder("<ConReq deliverPolyline=\"1\">");
conReq.append("<Start>").append(locationXml(from));
Expand Down Expand Up @@ -1298,7 +1298,7 @@ protected static final int locationType(final Location location) {
protected void appendQueryTripsBinaryParameters(final HttpUrl.Builder url, final Location from,
final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
final @Nullable Set<TripFlag> flags) {
url.addQueryParameter("start", "Suchen");
url.addEncodedQueryParameter("REQ0JourneyStopsS0ID",
ParserUtils.urlEncode(locationId(from), requestUrlEncoding));
Expand Down Expand Up @@ -1340,7 +1340,7 @@ else if (accessibility == Accessibility.BARRIER_FREE)
url.addQueryParameter("REQ0AddParamBaimprofile", "0");
}

if (options != null && options.contains(Option.BIKE))
if (flags != null && flags.contains(TripFlag.BIKE))
url.addQueryParameter("REQ0JourneyProduct_opt3", "1");

appendCommonQueryTripsBinaryParameters(url);
Expand Down Expand Up @@ -1390,7 +1390,7 @@ protected final QueryTripsResult queryTripsBinary(Location from, @Nullable Locat

final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage);
appendQueryTripsBinaryParameters(url, from, via, to, date, dep, options.products, options.accessibility,
options.options);
options.flags);
return queryTripsBinary(url.build(), from, via, to, QUERY_TRIPS_BINARY_BUFFER_SIZE);
}

Expand Down
2 changes: 1 addition & 1 deletion enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ public QueryTripsResult queryTrips(final Location from, final @Nullable Location
url.addQueryParameter("walking_speed", Double.toString(walkingSpeed));
}

if (options.options != null && options.options.contains(Option.BIKE)) {
if (options.flags != null && options.flags.contains(TripFlag.BIKE)) {
url.addQueryParameter("first_section_mode", "bike");
url.addQueryParameter("last_section_mode", "bike");
}
Expand Down
4 changes: 2 additions & 2 deletions enabler/src/de/schildbach/pte/AbstractNetworkProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public final boolean hasCapabilities(final Capability... capabilities) {
@Override
public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException {
@Nullable Accessibility accessibility, @Nullable Set<TripFlag> flags) throws IOException {
return queryTrips(from, via, to, date, dep,
new TripOptions(products, optimize, walkSpeed, accessibility, options));
new TripOptions(products, optimize, walkSpeed, accessibility, flags));
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions enabler/src/de/schildbach/pte/NetworkProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum Accessibility {
NEUTRAL, LIMITED, BARRIER_FREE
}

public enum Option {
public enum TripFlag {
BIKE
}

Expand Down Expand Up @@ -151,7 +151,7 @@ QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to,
@Deprecated
QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException;
@Nullable Accessibility accessibility, @Nullable Set<TripFlag> flags) throws IOException;

/**
* Query more trips (e.g. earlier or later)
Expand Down
16 changes: 8 additions & 8 deletions enabler/src/de/schildbach/pte/dto/TripOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import de.schildbach.pte.NetworkProvider;
import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.Optimize;
import de.schildbach.pte.NetworkProvider.Option;
import de.schildbach.pte.NetworkProvider.TripFlag;
import de.schildbach.pte.NetworkProvider.WalkSpeed;

/**
Expand All @@ -40,7 +40,7 @@ public class TripOptions {
public final @Nullable Optimize optimize;
public final @Nullable WalkSpeed walkSpeed;
public final @Nullable Accessibility accessibility;
public final @Nullable Set<Option> options;
public final @Nullable Set<TripFlag> flags;

/**
* @param products
Expand All @@ -51,24 +51,24 @@ public class TripOptions {
* walking ability, or {@code null} for the provider default
* @param accessibility
* route accessibility, or {@code null} for the provider default
* @param options
* additional options, or {@code null} for the provider default
* @param flags
* additional flags, or {@code null} for the provider default
*/
public TripOptions(@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
@Nullable Accessibility accessibility, @Nullable Set<Option> options) {
@Nullable Accessibility accessibility, @Nullable Set<TripFlag> flags) {
this.products = products;
this.optimize = optimize;
this.walkSpeed = walkSpeed;
this.accessibility = accessibility;
this.options = options;
this.flags = flags;
}

public TripOptions() {
this.products = null;
this.optimize = null;
this.walkSpeed = null;
this.accessibility = null;
this.options = null;
this.flags = null;
}

@Override
Expand All @@ -78,7 +78,7 @@ public String toString() {
helper.addValue(optimize);
helper.addValue(walkSpeed);
helper.addValue(accessibility);
helper.add("options", options);
helper.add("flags", flags);
return helper.toString();
}
}

0 comments on commit 2e5f16d

Please sign in to comment.