Make setters concatenable.

This commit is contained in:
Andreas Schildbach 2016-12-25 09:52:25 +01:00
parent 86b2d5a2f3
commit 349aee9aac
3 changed files with 74 additions and 37 deletions

View file

@ -175,57 +175,70 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
this.coordEndpoint = coordEndpoint; this.coordEndpoint = coordEndpoint;
} }
protected void setLanguage(final String language) { protected AbstractEfaProvider setLanguage(final String language) {
this.language = language; this.language = language;
return this;
} }
protected void setAdditionalQueryParameter(final String additionalQueryParameter) { protected AbstractEfaProvider setAdditionalQueryParameter(final String additionalQueryParameter) {
this.additionalQueryParameter = additionalQueryParameter; this.additionalQueryParameter = additionalQueryParameter;
return this;
} }
protected void setRequestUrlEncoding(final Charset requestUrlEncoding) { protected AbstractEfaProvider setRequestUrlEncoding(final Charset requestUrlEncoding) {
this.requestUrlEncoding = requestUrlEncoding; this.requestUrlEncoding = requestUrlEncoding;
return this;
} }
protected void setHttpReferer(final String httpReferer) { protected AbstractEfaProvider setHttpReferer(final String httpReferer) {
this.httpReferer = httpReferer; this.httpReferer = httpReferer;
this.httpRefererTrip = httpReferer; this.httpRefererTrip = httpReferer;
return this;
} }
public void setHttpRefererTrip(final String httpRefererTrip) { public AbstractEfaProvider setHttpRefererTrip(final String httpRefererTrip) {
this.httpRefererTrip = httpRefererTrip; this.httpRefererTrip = httpRefererTrip;
return this;
} }
protected void setHttpPost(final boolean httpPost) { protected AbstractEfaProvider setHttpPost(final boolean httpPost) {
this.httpPost = httpPost; this.httpPost = httpPost;
return this;
} }
protected void setIncludeRegionId(final boolean includeRegionId) { protected AbstractEfaProvider setIncludeRegionId(final boolean includeRegionId) {
this.includeRegionId = includeRegionId; this.includeRegionId = includeRegionId;
return this;
} }
protected void setUseProxFootSearch(final boolean useProxFootSearch) { protected AbstractEfaProvider setUseProxFootSearch(final boolean useProxFootSearch) {
this.useProxFootSearch = useProxFootSearch; this.useProxFootSearch = useProxFootSearch;
return this;
} }
protected void setUseRouteIndexAsTripId(final boolean useRouteIndexAsTripId) { protected AbstractEfaProvider setUseRouteIndexAsTripId(final boolean useRouteIndexAsTripId) {
this.useRouteIndexAsTripId = useRouteIndexAsTripId; this.useRouteIndexAsTripId = useRouteIndexAsTripId;
return this;
} }
protected void setUseLineRestriction(final boolean useLineRestriction) { protected AbstractEfaProvider setUseLineRestriction(final boolean useLineRestriction) {
this.useLineRestriction = useLineRestriction; this.useLineRestriction = useLineRestriction;
return this;
} }
protected void setUseStringCoordListOutputFormat(final boolean useStringCoordListOutputFormat) { protected AbstractEfaProvider setUseStringCoordListOutputFormat(final boolean useStringCoordListOutputFormat) {
this.useStringCoordListOutputFormat = useStringCoordListOutputFormat; this.useStringCoordListOutputFormat = useStringCoordListOutputFormat;
return this;
} }
protected void setNeedsSpEncId(final boolean needsSpEncId) { protected AbstractEfaProvider setNeedsSpEncId(final boolean needsSpEncId) {
this.needsSpEncId = needsSpEncId; this.needsSpEncId = needsSpEncId;
return this;
} }
protected void setFareCorrectionFactor(final float fareCorrectionFactor) { protected AbstractEfaProvider setFareCorrectionFactor(final float fareCorrectionFactor) {
this.fareCorrectionFactor = fareCorrectionFactor; this.fareCorrectionFactor = fareCorrectionFactor;
return this;
} }
@Override @Override

View file

@ -218,72 +218,89 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
this.productsMap = productsMap; this.productsMap = productsMap;
} }
protected void setStationBoardEndpoint(final String stationBoardEndpoint) { protected AbstractHafasProvider setStationBoardEndpoint(final String stationBoardEndpoint) {
this.stationBoardEndpoint = stationBoardEndpoint; this.stationBoardEndpoint = stationBoardEndpoint;
return this;
} }
protected void setGetStopEndpoint(final String getStopEndpoint) { protected AbstractHafasProvider setGetStopEndpoint(final String getStopEndpoint) {
this.getStopEndpoint = getStopEndpoint; this.getStopEndpoint = getStopEndpoint;
return this;
} }
protected void setQueryEndpoint(final String queryEndpoint) { protected AbstractHafasProvider setQueryEndpoint(final String queryEndpoint) {
this.queryEndpoint = queryEndpoint; this.queryEndpoint = queryEndpoint;
return this;
} }
protected void setExtXmlEndpoint(final String extXmlEndpoint) { protected AbstractHafasProvider setExtXmlEndpoint(final String extXmlEndpoint) {
this.extXmlEndpoint = extXmlEndpoint; this.extXmlEndpoint = extXmlEndpoint;
return this;
} }
protected void setAccessId(final String accessId) { protected AbstractHafasProvider setAccessId(final String accessId) {
this.accessId = accessId; this.accessId = accessId;
return this;
} }
protected void setClientType(final String clientType) { protected AbstractHafasProvider setClientType(final String clientType) {
this.clientType = clientType; this.clientType = clientType;
return this;
} }
protected void setJsonApiVersion(final String jsonApiVersion) { protected AbstractHafasProvider setJsonApiVersion(final String jsonApiVersion) {
this.jsonApiVersion = jsonApiVersion; this.jsonApiVersion = jsonApiVersion;
return this;
} }
protected void setJsonApiAuthorization(final String jsonApiAuthorization) { protected AbstractHafasProvider setJsonApiAuthorization(final String jsonApiAuthorization) {
this.jsonApiAuthorization = jsonApiAuthorization; this.jsonApiAuthorization = jsonApiAuthorization;
return this;
} }
protected void setJsonApiClient(final String jsonApiClient) { protected AbstractHafasProvider setJsonApiClient(final String jsonApiClient) {
this.jsonApiClient = jsonApiClient; this.jsonApiClient = jsonApiClient;
return this;
} }
protected void setDominantPlanStopTime(final boolean dominantPlanStopTime) { protected AbstractHafasProvider setDominantPlanStopTime(final boolean dominantPlanStopTime) {
this.dominantPlanStopTime = dominantPlanStopTime; this.dominantPlanStopTime = dominantPlanStopTime;
return this;
} }
protected void setJsonGetStopsEncoding(final Charset jsonGetStopsEncoding) { protected AbstractHafasProvider setJsonGetStopsEncoding(final Charset jsonGetStopsEncoding) {
this.jsonGetStopsEncoding = jsonGetStopsEncoding; this.jsonGetStopsEncoding = jsonGetStopsEncoding;
return this;
} }
protected void setJsonGetStopsUseWeight(final boolean jsonGetStopsUseWeight) { protected AbstractHafasProvider setJsonGetStopsUseWeight(final boolean jsonGetStopsUseWeight) {
this.jsonGetStopsUseWeight = jsonGetStopsUseWeight; this.jsonGetStopsUseWeight = jsonGetStopsUseWeight;
return this;
} }
protected void setJsonNearbyLocationsEncoding(final Charset jsonNearbyLocationsEncoding) { protected AbstractHafasProvider setJsonNearbyLocationsEncoding(final Charset jsonNearbyLocationsEncoding) {
this.jsonNearbyLocationsEncoding = jsonNearbyLocationsEncoding; this.jsonNearbyLocationsEncoding = jsonNearbyLocationsEncoding;
return this;
} }
protected void setUseIso8601(final boolean useIso8601) { protected AbstractHafasProvider setUseIso8601(final boolean useIso8601) {
this.useIso8601 = useIso8601; this.useIso8601 = useIso8601;
return this;
} }
protected void setStationBoardHasStationTable(final boolean stationBoardHasStationTable) { protected AbstractHafasProvider setStationBoardHasStationTable(final boolean stationBoardHasStationTable) {
this.stationBoardHasStationTable = stationBoardHasStationTable; this.stationBoardHasStationTable = stationBoardHasStationTable;
return this;
} }
protected void setStationBoardHasLocation(final boolean stationBoardHasLocation) { protected AbstractHafasProvider setStationBoardHasLocation(final boolean stationBoardHasLocation) {
this.stationBoardHasLocation = stationBoardHasLocation; this.stationBoardHasLocation = stationBoardHasLocation;
return this;
} }
protected void setStationBoardCanDoEquivs(final boolean canDoEquivs) { protected AbstractHafasProvider setStationBoardCanDoEquivs(final boolean canDoEquivs) {
this.stationBoardCanDoEquivs = canDoEquivs; this.stationBoardCanDoEquivs = canDoEquivs;
return this;
} }
@Override @Override
@ -3125,8 +3142,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
} }
} }
protected void setHtmlNearbyStationsPattern(final Pattern htmlNearbyStationsPattern) { protected AbstractHafasProvider setHtmlNearbyStationsPattern(final Pattern htmlNearbyStationsPattern) {
this.htmlNearbyStationsPattern = htmlNearbyStationsPattern; this.htmlNearbyStationsPattern = htmlNearbyStationsPattern;
return this;
} }
private Pattern htmlNearbyStationsPattern = Pattern.compile("<tr class=\"(zebra[^\"]*)\">(.*?)</tr>", private Pattern htmlNearbyStationsPattern = Pattern.compile("<tr class=\"(zebra[^\"]*)\">(.*?)</tr>",

View file

@ -75,28 +75,34 @@ public abstract class AbstractNetworkProvider implements NetworkProvider {
return ALL_EXCEPT_HIGHSPEED; return ALL_EXCEPT_HIGHSPEED;
} }
public void setUserAgent(final String userAgent) { public AbstractNetworkProvider setUserAgent(final String userAgent) {
httpClient.setUserAgent(userAgent); httpClient.setUserAgent(userAgent);
return this;
} }
public void setProxy(final Proxy proxy) { public AbstractNetworkProvider setProxy(final Proxy proxy) {
httpClient.setProxy(proxy); httpClient.setProxy(proxy);
return this;
} }
protected void setTimeZone(final String timeZoneId) { protected AbstractNetworkProvider setTimeZone(final String timeZoneId) {
this.timeZone = TimeZone.getTimeZone(timeZoneId); this.timeZone = TimeZone.getTimeZone(timeZoneId);
return this;
} }
protected void setNumTripsRequested(final int numTripsRequested) { protected AbstractNetworkProvider setNumTripsRequested(final int numTripsRequested) {
this.numTripsRequested = numTripsRequested; this.numTripsRequested = numTripsRequested;
return this;
} }
protected void setStyles(final Map<String, Style> styles) { protected AbstractNetworkProvider setStyles(final Map<String, Style> styles) {
this.styles = styles; this.styles = styles;
return this;
} }
protected void setSessionCookieName(final String sessionCookieName) { protected AbstractNetworkProvider setSessionCookieName(final String sessionCookieName) {
httpClient.setSessionCookieName(sessionCookieName); httpClient.setSessionCookieName(sessionCookieName);
return this;
} }
private static final char STYLES_SEP = '|'; private static final char STYLES_SEP = '|';