From 25a3052a54fe2c5b5afb7c85bfc0015bd06b44ab Mon Sep 17 00:00:00 2001 From: oblonski Date: Thu, 27 Sep 2018 09:34:15 +0200 Subject: [PATCH] remove redundant specifications --- .../core/problem/VehicleRoutingProblem.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblem.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblem.java index c54ed687..fa6afae5 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblem.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblem.java @@ -77,31 +77,29 @@ public class VehicleRoutingProblem { private VehicleRoutingActivityCosts activityCosts = new WaitingTimeCosts(); - private Map jobs = new LinkedHashMap(); + private Map jobs = new LinkedHashMap<>(); - private Map tentativeJobs = new LinkedHashMap(); + private Map tentativeJobs = new LinkedHashMap<>(); - private Map jobsInInitialRoutes = new HashMap<>(); + private Map jobsInInitialRoutes = new LinkedHashMap<>(); - private Map tentative_coordinates = new HashMap(); + private Map tentative_coordinates = new HashMap<>(); private FleetSize fleetSize = FleetSize.INFINITE; private Map vehicleTypes = new HashMap<>(); - private Collection initialRoutes = new ArrayList(); + private Collection initialRoutes = new ArrayList<>(); - private Set uniqueVehicles = new LinkedHashSet(); + private Set uniqueVehicles = new LinkedHashSet<>(); - private Set addedVehicleIds = new LinkedHashSet(); - - private boolean hasBreaks = false; + private Set addedVehicleIds = new LinkedHashSet<>(); private JobActivityFactory jobActivityFactory = new JobActivityFactory() { @Override public List createActivities(Job job) { - List acts = new ArrayList(); + List acts = new ArrayList<>(); if( job instanceof Break){ acts.add(BreakActivity.newInstance((Break) job)); } @@ -122,9 +120,9 @@ public class VehicleRoutingProblem { private int vehicleTypeIdIndexCounter = 1; - private Map typeKeyIndices = new HashMap(); + private Map typeKeyIndices = new HashMap<>(); - private Map> activityMap = new HashMap>(); + private Map> activityMap = new HashMap<>(); private final DefaultShipmentActivityFactory shipmentActivityFactory = new DefaultShipmentActivityFactory(); @@ -138,7 +136,7 @@ public class VehicleRoutingProblem { vehicleTypeIdIndexCounter++; } - private Set allLocations = new HashSet(); + private Set allLocations = new HashSet<>(); /** * Returns the unmodifiable map of collected locations (mapped by their location-id). @@ -323,7 +321,7 @@ public class VehicleRoutingProblem { private void registerJobAndActivity(AbstractActivity abstractAct, Job job) { if (activityMap.containsKey(job)) activityMap.get(job).add(abstractAct); else { - List actList = new ArrayList(); + List actList = new ArrayList<>(); actList.add(abstractAct); activityMap.put(job, actList); } @@ -439,7 +437,7 @@ public class VehicleRoutingProblem { addJobToFinalJobMapAndCreateActivities(job); } } - + int jobIndexCounter = 1; for (Job job : jobs.values()) { ((AbstractJob)job).setIndex(jobIndexCounter++); @@ -447,13 +445,14 @@ public class VehicleRoutingProblem { for (Job job : jobsInInitialRoutes.values()) { ((AbstractJob)job).setIndex(jobIndexCounter++); } - + boolean hasBreaks = addBreaksToActivityMap(); if (hasBreaks && fleetSize.equals(FleetSize.INFINITE)) throw new UnsupportedOperationException("Breaks are not yet supported when dealing with infinite fleet. Either set it to finite or omit breaks."); return new VehicleRoutingProblem(this); } + @Deprecated public Builder addLocation(String locationId, Coordinate coordinate) { tentative_coordinates.put(locationId, coordinate); return this; @@ -531,7 +530,7 @@ public class VehicleRoutingProblem { * * @author sschroeder */ - public static enum FleetSize { + public enum FleetSize { FINITE, INFINITE } @@ -641,7 +640,7 @@ public class VehicleRoutingProblem { * @return copied collection of initial vehicle routes */ public Collection getInitialVehicleRoutes() { - Collection copiedInitialRoutes = new ArrayList(); + Collection copiedInitialRoutes = new ArrayList<>(); for (VehicleRoute route : initialVehicleRoutes) { copiedInitialRoutes.add(VehicleRoute.copyOf(route)); } @@ -718,7 +717,7 @@ public class VehicleRoutingProblem { * @return a copy of the activities that are associated to the specified job */ public List copyAndGetActivities(Job job) { - List acts = new ArrayList(); + List acts = new ArrayList<>(); if (activityMap.containsKey(job)) { for (AbstractActivity act : activityMap.get(job)) acts.add((AbstractActivity) act.duplicate()); }