mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
rename VehicleBuilder to Builder; adapt VehicleFleetManagerTest to
changes in VehicleFleetManager
This commit is contained in:
parent
c1849a9d5a
commit
7386ba7309
24 changed files with 137 additions and 91 deletions
|
|
@ -62,7 +62,7 @@ final class CalculatesVehTypeDepServiceInsertion implements JobInsertionCalculat
|
|||
Collection<Vehicle> relevantVehicles = new ArrayList<Vehicle>();
|
||||
if(!(selectedVehicle instanceof NoVehicle)) {
|
||||
relevantVehicles.add(selectedVehicle);
|
||||
relevantVehicles.addAll(fleetManager.getAvailableVehicle(selectedVehicle.getType().getTypeId(),selectedVehicle.getLocationId()));
|
||||
relevantVehicles.addAll(fleetManager.getAvailableVehicles(selectedVehicle.getType().getTypeId(),selectedVehicle.getLocationId()));
|
||||
}
|
||||
else{
|
||||
relevantVehicles.addAll(fleetManager.getAvailableVehicles());
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ final class FindCheaperVehicleAlgo {
|
|||
path.addAll(vehicleRoute.getTourActivities().getActivities());
|
||||
path.add(vehicleRoute.getEnd());
|
||||
|
||||
for(Vehicle vehicle : fleetManager.getAvailableVehicle(vehicleRoute.getVehicle().getType().getTypeId(), vehicleRoute.getVehicle().getLocationId())){
|
||||
for(Vehicle vehicle : fleetManager.getAvailableVehicles(vehicleRoute.getVehicle().getType().getTypeId(), vehicleRoute.getVehicle().getLocationId())){
|
||||
// Vehicle vehicle = fleetManager.getEmptyVehicle(vehicleType);
|
||||
if(vehicle.getType().getTypeId().equals(vehicleRoute.getVehicle().getType().getTypeId())){
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -92,13 +92,13 @@ class InfiniteVehicles implements VehicleFleetManager{
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Vehicle> getAvailableVehicles() {
|
||||
public Collection<Vehicle> getAvailableVehicles() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Vehicle> getAvailableVehicle(
|
||||
public Collection<Vehicle> getAvailableVehicles(
|
||||
String withoutThisType, String locationId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ interface VehicleFleetManager {
|
|||
|
||||
abstract void unlockAll();
|
||||
|
||||
abstract Collection<? extends Vehicle> getAvailableVehicles();
|
||||
abstract Collection<Vehicle> getAvailableVehicles();
|
||||
|
||||
Collection<? extends Vehicle> getAvailableVehicle(String withoutThisType, String locationId);
|
||||
Collection<Vehicle> getAvailableVehicles(String withoutThisType, String locationId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
|||
* this type and location. If so, it returns this penalty vehicle. If not, no vehicle with this type and location is returned.
|
||||
*/
|
||||
@Override
|
||||
public Collection<? extends Vehicle> getAvailableVehicles() {
|
||||
public Collection<Vehicle> getAvailableVehicles() {
|
||||
List<Vehicle> vehicles = new ArrayList<Vehicle>();
|
||||
for(TypeKey key : typeMapOfAvailableVehicles.keySet()){
|
||||
if(!typeMapOfAvailableVehicles.get(key).isEmpty()){
|
||||
|
|
@ -195,7 +195,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager {
|
|||
* @return collection of available vehicles without the vehicles that have the typeId 'withoutThisType' AND the locationId 'withThisLocation'.
|
||||
*/
|
||||
@Override
|
||||
public Collection<? extends Vehicle> getAvailableVehicle(String withoutThisType, String withThisLocationId) {
|
||||
public Collection<Vehicle> getAvailableVehicles(String withoutThisType, String withThisLocationId) {
|
||||
List<Vehicle> vehicles = new ArrayList<Vehicle>();
|
||||
TypeKey thisKey = new TypeKey(withoutThisType,withThisLocationId);
|
||||
for(TypeKey key : typeMapOfAvailableVehicles.keySet()){
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import basics.route.Start;
|
|||
import basics.route.TimeWindow;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleImpl.VehicleBuilder;
|
||||
import basics.route.VehicleImpl.Builder;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleType;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
|
@ -284,7 +284,7 @@ public class VrpXMLReader{
|
|||
for(HierarchicalConfiguration vehicleConfig : vehicleConfigs){
|
||||
String vehicleId = vehicleConfig.getString("id");
|
||||
if(vehicleId == null) throw new IllegalStateException("vehicleId is missing.");
|
||||
VehicleBuilder builder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
||||
Builder builder = VehicleImpl.Builder.newInstance(vehicleId);
|
||||
String typeId = vehicleConfig.getString("typeId");
|
||||
if(typeId == null) throw new IllegalStateException("typeId is missing.");
|
||||
VehicleTypeImpl type = types.get(typeId);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class VehicleImpl implements Vehicle {
|
|||
public static class NoVehicle extends VehicleImpl {
|
||||
|
||||
public NoVehicle() {
|
||||
super(VehicleBuilder.newInstance("noVehicle").setType(VehicleTypeImpl.newInstance(null, 0, null)));
|
||||
super(Builder.newInstance("noVehicle").setType(VehicleTypeImpl.newInstance(null, 0, null)));
|
||||
}
|
||||
|
||||
public int getCapacity(){
|
||||
|
|
@ -40,8 +40,8 @@ public class VehicleImpl implements Vehicle {
|
|||
|
||||
}
|
||||
|
||||
public static class VehicleBuilder {
|
||||
static Logger log = Logger.getLogger(VehicleBuilder.class);
|
||||
public static class Builder {
|
||||
static Logger log = Logger.getLogger(Builder.class);
|
||||
private String id;
|
||||
|
||||
private String locationId;
|
||||
|
|
@ -51,32 +51,32 @@ public class VehicleImpl implements Vehicle {
|
|||
|
||||
private VehicleType type = VehicleTypeImpl.Builder.newInstance("default", 0).build();
|
||||
|
||||
private VehicleBuilder(String id) {
|
||||
private Builder(String id) {
|
||||
super();
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public VehicleBuilder setType(VehicleType type){
|
||||
public Builder setType(VehicleType type){
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VehicleBuilder setLocationId(String id){
|
||||
public Builder setLocationId(String id){
|
||||
this.locationId = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VehicleBuilder setLocationCoord(Coordinate coord){
|
||||
public Builder setLocationCoord(Coordinate coord){
|
||||
this.locationCoord = coord;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VehicleBuilder setEarliestStart(double start){
|
||||
public Builder setEarliestStart(double start){
|
||||
this.earliestStart = start;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VehicleBuilder setLatestArrival(double arr){
|
||||
public Builder setLatestArrival(double arr){
|
||||
this.latestArrival = arr;
|
||||
return this;
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ public class VehicleImpl implements Vehicle {
|
|||
return new VehicleImpl(this);
|
||||
}
|
||||
|
||||
public static VehicleBuilder newInstance(String vehicleId){ return new VehicleBuilder(vehicleId); }
|
||||
public static Builder newInstance(String vehicleId){ return new Builder(vehicleId); }
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ public class VehicleImpl implements Vehicle {
|
|||
|
||||
private final double latestArrival;
|
||||
|
||||
private VehicleImpl(VehicleBuilder builder){
|
||||
private VehicleImpl(Builder builder){
|
||||
id = builder.id;
|
||||
type = builder.type;
|
||||
coord = builder.locationCoord;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue