Skip to content

Commit

Permalink
rename setters in Builder to make it more consistent. old setters rem…
Browse files Browse the repository at this point in the history
…ain as deprecated
  • Loading branch information
kt86 committed Dec 20, 2024
1 parent da488be commit 10071db
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,40 @@ private Builder(Id<CarrierService> id, Id<Link> serviceLinkId) {
this.serviceLinkId = serviceLinkId;
}

public CarrierService build(){
return new CarrierService(this);
}


/**
* By default, it is [0.0,Integer.MaxValue].
* Sets a time-window for the beginning of the service
* When not set, it is by default [0.0., Integer.MAX_VALUE].
* <p>
* Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that
* time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd().
*
* @param serviceDuration duration of the service
* @param startTimeWindow time-window for the beginning of the service acti
* @return the builder
*/
public Builder setServiceDuration(double serviceDuration){
this.serviceDuration = serviceDuration;
public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){
this.serviceStartsTimeWindow = startTimeWindow;
return this;
}

/**
* Sets a time-window for the service.
*
* <p>Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that
* time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd().
* Sets the duration for the pickup activity.
* When not set, it is by default 0.0.
*
* @param startTimeWindow time-window for the service
* @param serviceDuration duration of the service
* @return the builder
*/
public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){
this.serviceStartsTimeWindow = startTimeWindow;
public Builder setServiceDuration(double serviceDuration){
this.serviceDuration = serviceDuration;
return this;
}

public CarrierService build(){
return new CarrierService(this);
}



public Builder setCapacityDemand(int value) {
this.demand = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ public static Builder newInstance(Id<Link> from, Id<Link> to, int size){

/**
* Returns a new shipment builder.
* <p> The builder is init with the shipment's origin (from), destination (to) and with the shipment's size.
* <p> The builder is init with the shipment's origin (from), destination (to) and with the shipment's demand.
* The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()].
*
* @param id the id of the shipment
* @param from the origin
* @param to the destination
* @param size size of the shipment
* @param demand demand of the shipment
* @return the builder
*/
public static Builder newInstance(Id<CarrierShipment> id, Id<Link> from, Id<Link> to, int size){
return new Builder(id, from,to,size);
public static Builder newInstance(Id<CarrierShipment> id, Id<Link> from, Id<Link> to, int demand){
return new Builder(id, from, to, demand);
}

/**
Expand All @@ -110,29 +110,101 @@ private Builder(Id<CarrierShipment> id, Id<Link> pickupLinkId, Id<Link> delivery
this.demand = demand;
}

public Builder setPickupTimeWindow(TimeWindow pickupTW){
this.pickupStartsTimeWindow = pickupTW;
/**
* Sets a time-window for the beginning of the pickup
* When not set, it is by default [0.0., Integer.MAX_VALUE].
* <p>
* Note that the time-window restricts the start-time of the shipment's pickup . If one works with hard time-windows (which means that
* time-windows must be met) than the pickup is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd().
*
* @param pickupStartsTimeWindow time-window for the beginning of the pickup activity
* @return the builder
*/
public Builder setPickupStartsTimeWindow(TimeWindow pickupStartsTimeWindow){
this.pickupStartsTimeWindow = pickupStartsTimeWindow;
return this;
}

public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){
this.deliveryStartsTimeWindow = deliveryTW;
/**
* Sets the duration for the pickup activity.
* When not set, it is by default 0.0.
*
* @param pickupDuration Duration of the pickup activity (in seconds).
* @return the Builder
*/
public Builder setPickupDuration(double pickupDuration){
this.pickupDuration = pickupDuration;
return this;
}

public Builder setPickupServiceTime(double pickupServiceTime){
this.pickupDuration = pickupServiceTime;
/**
* Sets a time-window for the beginning of the delivery
* When not set, it is by default [0.0., Integer.MAX_VALUE].
* <p>
* Note that the time-window restricts the start-time of the shipment's delivery . If one works with hard time-windows (which means that
* time-windows must be met) than the delivery is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd().
*
* @param deliveryStartsTimeWindow time-window for the beginning of the delivery activity
* @return the builder
*/
public Builder setDeliveryStartsTimeWindow(TimeWindow deliveryStartsTimeWindow){
this.deliveryStartsTimeWindow = deliveryStartsTimeWindow;
return this;
}

public Builder setDeliveryServiceTime(double deliveryServiceTime){
this.deliveryDuration = deliveryServiceTime;
/**
* Sets the duration for the delivery activity.
* When not set, it is by default 0.0.
*
* @param deliveryDuration Duration of the delivery activity (in seconds).
* @return the Builder
*/
public Builder setDeliveryDuration(double deliveryDuration){
this.deliveryDuration = deliveryDuration;
return this;
}

public CarrierShipment build(){
return new CarrierShipment(this);
}

//*** deprecated methods ***


/**
* @deprecated please inline and use {@link #setPickupStartsTimeWindow(TimeWindow)} instead
*/
@Deprecated(since = "dez 2024")
public Builder setPickupTimeWindow(TimeWindow pickupTW){
return setPickupStartsTimeWindow(pickupTW);
}

/**
* @deprecated please inline and use {@link #setPickupDuration(double)} instead
*/
@Deprecated(since = "dez 2024")
public Builder setPickupServiceTime(double pickupServiceTime){
return setPickupDuration(pickupServiceTime);
}

/**
* @deprecated please inline and use {@link #setDeliveryStartsTimeWindow(TimeWindow)} instead
*/
@Deprecated(since = "dez 2024")
public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){
return setDeliveryStartsTimeWindow(deliveryTW);
}

/**
* @deprecated please inline and use {@link #setDeliveryDuration(double)} instead
*/
@Deprecated(since = "dez 2024")
public Builder setDeliveryServiceTime(double deliveryServiceTime){
return setDeliveryDuration(deliveryServiceTime);
}



}

private final Id<CarrierShipment> id;
Expand Down

0 comments on commit 10071db

Please sign in to comment.