Skip to content

Commit

Permalink
rename internal variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Dec 20, 2024
1 parent 701b615 commit e700fea
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ public final class CarrierService implements CarrierJob {

public static class Builder {

public static Builder newInstance(Id<CarrierService> id, Id<Link> locationLinkId){
return new Builder(id,locationLinkId);
}

private final Id<CarrierService> id;
private int demand = 0;

private final Id<Link> locationLinkId;
private TimeWindow timeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE);
private double serviceTime = 0.0;
private final Id<Link> serviceLinkId;
private TimeWindow serviceStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE);
private double serviceDuration = 0.0;

public static Builder newInstance(Id<CarrierService> id, Id<Link> locationLinkId){
return new Builder(id,locationLinkId);
}

private Builder(Id<CarrierService> id, Id<Link> locationLinkId) {
private Builder(Id<CarrierService> id, Id<Link> serviceLinkId) {
super();
this.id = id;
this.locationLinkId = locationLinkId;
this.serviceLinkId = serviceLinkId;
}


Expand All @@ -55,7 +55,7 @@ private Builder(Id<CarrierService> id, Id<Link> locationLinkId) {
* @return the builder
*/
public Builder setServiceDuration(double serviceDuration){
this.serviceTime = serviceDuration;
this.serviceDuration = serviceDuration;
return this;
}

Expand All @@ -69,7 +69,7 @@ public Builder setServiceDuration(double serviceDuration){
* @return the builder
*/
public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){
this.timeWindow = startTimeWindow;
this.serviceStartsTimeWindow = startTimeWindow;
return this;
}

Expand All @@ -88,17 +88,17 @@ public Builder setCapacityDemand(int value) {
private final Id<CarrierService> id;
private final int demand;

private final Id<Link> locationId;
private final TimeWindow timeWindow;
private final Id<Link> serviceLinkId;
private final TimeWindow serviceStartsTimeWindow;
private final double serviceDuration;

private final Attributes attributes = new AttributesImpl();

private CarrierService(Builder builder){
id = builder.id;
locationId = builder.locationLinkId;
serviceDuration = builder.serviceTime;
timeWindow = builder.timeWindow;
serviceLinkId = builder.serviceLinkId;
serviceDuration = builder.serviceDuration;
serviceStartsTimeWindow = builder.serviceStartsTimeWindow;
demand = builder.demand;
}

Expand All @@ -107,18 +107,16 @@ public Id<CarrierService> getId() {
return id;
}



public Id<Link> getLocationLinkId() {
return locationId;
return serviceLinkId;
}

public double getServiceDuration() {
return serviceDuration;
}

public TimeWindow getServiceStartTimeWindow(){
return timeWindow;
return serviceStartsTimeWindow;
}

/**
Expand Down Expand Up @@ -146,7 +144,7 @@ public Attributes getAttributes() {

@Override
public String toString() {
return "[id=" + id + "][locationId=" + locationId + "][capacityDemand=" + demand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + timeWindow + "]";
return "[id=" + id + "][locationId=" + serviceLinkId + "][capacityDemand=" + demand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + serviceStartsTimeWindow + "]";
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ public final class CarrierShipment implements CarrierJob {
*/
public static class Builder {

Id<CarrierShipment> id;
final int demand;

final Id<Link> pickupLinkId;
TimeWindow pickupStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE);
double pickupDuration = 0.0;

final Id<Link> deliveryLinkId;
TimeWindow deliveryStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE);
double deliveryDuration = 0.0;


/**
* @deprecated Please use Builder newInstance(Id<CarrierShipment> id, Id<Link> from, Id<Link> to, int size) instead.
* <p>
Expand Down Expand Up @@ -77,53 +89,42 @@ public static Builder newInstance(Id<CarrierShipment> id, Id<Link> from, Id<Link
return new Builder(id, from,to,size);
}

Id<CarrierShipment> id;
final int size;

final Id<Link> from;
TimeWindow pickTW = TimeWindow.newInstance(0.0, Integer.MAX_VALUE);
double pickServiceTime = 0.0;

final Id<Link> to;
TimeWindow delTW = TimeWindow.newInstance(0.0, Integer.MAX_VALUE);
double delServiceTime = 0.0;

/**
* @deprecated Please use Builder (Id<CarrierShipment> id, Id<Link> from, Id<Link> to, int size) instead.
*/
@Deprecated
public Builder(Id<Link> from, Id<Link> to, int size) {
public Builder(Id<Link> pickupLinkId, Id<Link> deliveryLinkId, int demand) {
super();
this.from = from;
this.to = to;
this.size = size;
this.pickupLinkId = pickupLinkId;
this.deliveryLinkId = deliveryLinkId;
this.demand = demand;
}

public Builder(Id<CarrierShipment> id, Id<Link> from, Id<Link> to, int size) {
public Builder(Id<CarrierShipment> id, Id<Link> pickupLinkId, Id<Link> deliveryLinkId, int demand) {
super();
this.id = id;
this.from = from;
this.to = to;
this.size = size;
this.pickupLinkId = pickupLinkId;
this.deliveryLinkId = deliveryLinkId;
this.demand = demand;
}

public Builder setPickupTimeWindow(TimeWindow pickupTW){
this.pickTW = pickupTW;
this.pickupStartsTimeWindow = pickupTW;
return this;
}

public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){
this.delTW = deliveryTW;
this.deliveryStartsTimeWindow = deliveryTW;
return this;
}

public Builder setPickupServiceTime(double pickupServiceTime){
this.pickServiceTime = pickupServiceTime;
this.pickupDuration = pickupServiceTime;
return this;
}

public Builder setDeliveryServiceTime(double deliveryServiceTime){
this.delServiceTime = deliveryServiceTime;
this.deliveryDuration = deliveryServiceTime;
return this;
}

Expand All @@ -135,42 +136,42 @@ public CarrierShipment build(){
private final Id<CarrierShipment> id;
private final int demand;

private final Id<Link> from;
private final TimeWindow pickupTimeWindow;
private double pickupServiceTime;
private final Id<Link> pickupLinkId;
private final TimeWindow pickupStartsTimeWindow;
private double pickupDuration;

private final Id<Link> to;
private final TimeWindow deliveryTimeWindow;
private double deliveryServiceTime;
private final Id<Link> deliveryLinkId;
private final TimeWindow deliveryStartsTimeWindow;
private double deliveryDuration;

private final Attributes attributes = new AttributesImpl();


private CarrierShipment(Builder builder) {
id = builder.id;
from = builder.from;
to = builder.to;
demand = builder.size;
pickupServiceTime = builder.pickServiceTime;
deliveryServiceTime = builder.delServiceTime;
pickupTimeWindow = builder.pickTW;
deliveryTimeWindow = builder.delTW;
pickupLinkId = builder.pickupLinkId;
deliveryLinkId = builder.deliveryLinkId;
demand = builder.demand;
pickupDuration = builder.pickupDuration;
deliveryDuration = builder.deliveryDuration;
pickupStartsTimeWindow = builder.pickupStartsTimeWindow;
deliveryStartsTimeWindow = builder.deliveryStartsTimeWindow;
}

public double getPickupServiceTime() {
return pickupServiceTime;
return pickupDuration;
}

public void setPickupServiceTime(double pickupServiceTime) {
this.pickupServiceTime = pickupServiceTime;
public void setPickupServiceTime(double pickupDuration) {
this.pickupDuration = pickupDuration;
}

public double getDeliveryServiceTime() {
return deliveryServiceTime;
return deliveryDuration;
}

public void setDeliveryServiceTime(double deliveryServiceTime) {
this.deliveryServiceTime = deliveryServiceTime;
public void setDeliveryServiceTime(double deliveryDuration) {
this.deliveryDuration = deliveryDuration;
}

@Override
Expand All @@ -179,11 +180,11 @@ public Id<CarrierShipment> getId() {
}

public Id<Link> getFrom() {
return from;
return pickupLinkId;
}

public Id<Link> getTo() {
return to;
return deliveryLinkId;
}

/**
Expand All @@ -203,11 +204,11 @@ public int getDemand() {
}

public TimeWindow getPickupTimeWindow() {
return pickupTimeWindow;
return pickupStartsTimeWindow;
}

public TimeWindow getDeliveryTimeWindow() {
return deliveryTimeWindow;
return deliveryStartsTimeWindow;
}

@Override
Expand All @@ -217,8 +218,8 @@ public Attributes getAttributes() {

@Override
public String toString() {
return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + from.toString() + "][to=" + to.toString() + "][size=" + demand + "][pickupServiceTime=" + pickupServiceTime + "]" +
"[deliveryServiceTime="+deliveryServiceTime+"][pickupTimeWindow="+pickupTimeWindow+"][deliveryTimeWindow="+deliveryTimeWindow+"]";
return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + pickupLinkId.toString() + "][to=" + deliveryLinkId.toString() + "][size=" + demand + "][pickupServiceTime=" + pickupDuration + "]" +
"[deliveryServiceTime="+ deliveryDuration +"][pickupTimeWindow="+ pickupStartsTimeWindow +"][deliveryTimeWindow="+ deliveryStartsTimeWindow +"]";
}

/* (non-Javadoc)
Expand Down

0 comments on commit e700fea

Please sign in to comment.