Skip to content

Commit

Permalink
Add copy method to ParameterBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 22, 2023
1 parent fd8a447 commit 0ec263e
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class TripPlanParametersBuilder {

private Coordinate from;
private Coordinate coordinate;
private Coordinate to;
private LocalDateTime time;
private Set<RequestMode> modes;
private SearchDirection searchDirection = SearchDirection.DEPART_AT;
Expand All @@ -25,7 +25,7 @@ public TripPlanParametersBuilder withFrom(Coordinate from) {
}

public TripPlanParametersBuilder withTo(Coordinate coordinate) {
this.coordinate = coordinate;
this.to = coordinate;
return this;
}

Expand Down Expand Up @@ -64,8 +64,20 @@ public TripPlanParametersBuilder withWheelchair(boolean wheelchair) {
return this;
}

public TripPlanParametersBuilder copy() {
return TripPlanParameters.builder()
.withFrom(from)
.withTo(to)
.withTime(time)
.withModes(modes)
.withSearchDirection(searchDirection)
.withWalkReluctance(walkReluctance)
.withNumberOfItineraries(numItineraries)
.withWheelchair(wheelchair);
}

public TripPlanParameters build() {
return new TripPlanParameters(
from, coordinate, time, numItineraries, modes, searchDirection, walkReluctance, wheelchair);
from, to, time, numItineraries, modes, searchDirection, walkReluctance, wheelchair);
}
}

0 comments on commit 0ec263e

Please sign in to comment.