NetworkProvider: Rename Option to TripFlag.

This commit is contained in:
Andreas Schildbach 2018-11-05 19:19:07 +01:00
parent 0831d0f8e6
commit 2e5f16d3ef
6 changed files with 18 additions and 18 deletions

View file

@ -2057,7 +2057,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
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");

View file

@ -738,7 +738,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
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));
@ -1298,7 +1298,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
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));
@ -1340,7 +1340,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
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);
@ -1390,7 +1390,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
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);
}

View file

@ -920,7 +920,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
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");
}

View file

@ -81,9 +81,9 @@ public abstract class AbstractNetworkProvider implements NetworkProvider {
@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

View file

@ -65,7 +65,7 @@ public interface NetworkProvider {
NEUTRAL, LIMITED, BARRIER_FREE
}
public enum Option {
public enum TripFlag {
BIKE
}
@ -151,7 +151,7 @@ public interface NetworkProvider {
@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)

View file

@ -27,7 +27,7 @@ import com.google.common.base.MoreObjects.ToStringHelper;
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;
/**
@ -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
@ -51,16 +51,16 @@ 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() {
@ -68,7 +68,7 @@ public class TripOptions {
this.optimize = null;
this.walkSpeed = null;
this.accessibility = null;
this.options = null;
this.flags = null;
}
@Override
@ -78,7 +78,7 @@ public class TripOptions {
helper.addValue(optimize);
helper.addValue(walkSpeed);
helper.addValue(accessibility);
helper.add("options", options);
helper.add("flags", flags);
return helper.toString();
}
}