org.opentripplanner.routing.api.request.RequestModesBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.routing.api.request;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.opentripplanner.transit.model.basic.MainAndSubMode;
import org.opentripplanner.transit.model.basic.SubMode;
import org.opentripplanner.transit.model.basic.TransitMode;
public class RequestModesBuilder {
private StreetMode accessMode;
private StreetMode egressMode;
private StreetMode directMode;
private StreetMode transferMode;
private List transitModes;
RequestModesBuilder(RequestModes origin) {
this.accessMode = origin.accessMode;
this.egressMode = origin.egressMode;
this.directMode = origin.directMode;
this.transferMode = origin.transferMode;
this.transitModes = new ArrayList<>(origin.transitModes);
}
public StreetMode accessMode() {
return accessMode;
}
public RequestModesBuilder withAccessMode(StreetMode accessMode) {
this.accessMode = accessMode;
return this;
}
public StreetMode egressMode() {
return egressMode;
}
public RequestModesBuilder withEgressMode(StreetMode egressMode) {
this.egressMode = egressMode;
return this;
}
public StreetMode directMode() {
return directMode;
}
public RequestModesBuilder withDirectMode(StreetMode directMode) {
this.directMode = directMode;
return this;
}
public StreetMode transferMode() {
return transferMode;
}
public RequestModesBuilder withTransferMode(StreetMode transferMode) {
this.transferMode = transferMode;
return this;
}
public RequestModesBuilder withAllStreetModes(StreetMode streetMode) {
return withAccessMode(streetMode)
.withEgressMode(streetMode)
.withDirectMode(streetMode)
.withTransferMode(streetMode);
}
public List transitModes() {
return transitModes;
}
public RequestModesBuilder withTransitMode(TransitMode mainMode) {
this.transitModes.add(new MainAndSubMode(mainMode, null));
return this;
}
public RequestModesBuilder withTransitMode(TransitMode mainMode, String subMode) {
this.transitModes.add(new MainAndSubMode(mainMode, SubMode.of(subMode)));
return this;
}
public RequestModesBuilder clearTransitModes() {
this.transitModes.clear();
return this;
}
public RequestModesBuilder withTransitModes(Collection transitModes) {
this.transitModes = new ArrayList<>(transitModes);
return this;
}
public RequestModes build() {
return new RequestModes(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy