@@ -23,6 +23,7 @@ public final class CarPreferences implements Serializable {
23
23
public static final CarPreferences DEFAULT = new CarPreferences ();
24
24
25
25
private final double reluctance ;
26
+ private final Cost boardCost ;
26
27
private final VehicleParkingPreferences parking ;
27
28
private final VehicleRentalPreferences rental ;
28
29
private final Duration pickupTime ;
@@ -33,6 +34,7 @@ public final class CarPreferences implements Serializable {
33
34
/** Create a new instance with default values. */
34
35
private CarPreferences () {
35
36
this .reluctance = 2.0 ;
37
+ this .boardCost = Cost .costOfMinutes (10 );
36
38
this .parking = VehicleParkingPreferences .DEFAULT ;
37
39
this .rental = VehicleRentalPreferences .DEFAULT ;
38
40
this .pickupTime = Duration .ofMinutes (1 );
@@ -43,6 +45,7 @@ private CarPreferences() {
43
45
44
46
private CarPreferences (Builder builder ) {
45
47
this .reluctance = Units .reluctance (builder .reluctance );
48
+ this .boardCost = builder .boardCost ;
46
49
this .parking = builder .parking ;
47
50
this .rental = builder .rental ;
48
51
this .pickupTime = Duration .ofSeconds (Units .duration (builder .pickupTime ));
@@ -63,6 +66,15 @@ public double reluctance() {
63
66
return reluctance ;
64
67
}
65
68
69
+ /**
70
+ * Separate cost for boarding a vehicle with a car, which is different compared to on foot or with a bicycle. This
71
+ * is in addition to the cost of the transfer and waiting-time. It is also in addition to
72
+ * the {@link TransferPreferences#cost()}.
73
+ */
74
+ public int boardCost () {
75
+ return boardCost .toSeconds ();
76
+ }
77
+
66
78
/** Parking preferences that can be different per request */
67
79
public VehicleParkingPreferences parking () {
68
80
return parking ;
@@ -106,6 +118,7 @@ public boolean equals(Object o) {
106
118
CarPreferences that = (CarPreferences ) o ;
107
119
return (
108
120
DoubleUtils .doubleEquals (that .reluctance , reluctance ) &&
121
+ boardCost .equals (that .boardCost ) &&
109
122
parking .equals (that .parking ) &&
110
123
rental .equals (that .rental ) &&
111
124
Objects .equals (pickupTime , that .pickupTime ) &&
@@ -119,6 +132,7 @@ public boolean equals(Object o) {
119
132
public int hashCode () {
120
133
return Objects .hash (
121
134
reluctance ,
135
+ boardCost ,
122
136
parking ,
123
137
rental ,
124
138
pickupTime ,
@@ -133,6 +147,7 @@ public String toString() {
133
147
return ToStringBuilder
134
148
.of (CarPreferences .class )
135
149
.addNum ("reluctance" , reluctance , DEFAULT .reluctance )
150
+ .addObj ("boardCost" , boardCost , DEFAULT .boardCost )
136
151
.addObj ("parking" , parking , DEFAULT .parking )
137
152
.addObj ("rental" , rental , DEFAULT .rental )
138
153
.addObj ("pickupTime" , pickupTime , DEFAULT .pickupTime )
@@ -147,6 +162,7 @@ public static class Builder {
147
162
148
163
private final CarPreferences original ;
149
164
private double reluctance ;
165
+ private Cost boardCost ;
150
166
private VehicleParkingPreferences parking ;
151
167
private VehicleRentalPreferences rental ;
152
168
private int pickupTime ;
@@ -157,6 +173,7 @@ public static class Builder {
157
173
public Builder (CarPreferences original ) {
158
174
this .original = original ;
159
175
this .reluctance = original .reluctance ;
176
+ this .boardCost = original .boardCost ;
160
177
this .parking = original .parking ;
161
178
this .rental = original .rental ;
162
179
this .pickupTime = (int ) original .pickupTime .toSeconds ();
@@ -174,6 +191,15 @@ public Builder withReluctance(double reluctance) {
174
191
return this ;
175
192
}
176
193
194
+ public Cost boardCost () {
195
+ return boardCost ;
196
+ }
197
+
198
+ public Builder withBoardCost (int boardCost ) {
199
+ this .boardCost = Cost .costOfSeconds (boardCost );
200
+ return this ;
201
+ }
202
+
177
203
public Builder withParking (Consumer <VehicleParkingPreferences .Builder > body ) {
178
204
this .parking = ifNotNull (this .parking , original .parking ).copyOf ().apply (body ).build ();
179
205
return this ;
0 commit comments