public void loadNext(Track destTrack) { setLoadGeneratedFromStaging(false); // update wait count setWait(getNextWait()); setNextWait(0); // and the pickup day setPickupScheduleId(getNextPickupScheduleId()); setNextPickupScheduleId(NONE); // arrived at spur? if (destTrack != null && destTrack.getTrackType().equals(Track.SPUR)) { updateLoad(); } // update load optionally when car reaches staging else if (destTrack != null && destTrack.getTrackType().equals(Track.STAGING)) { if (destTrack.isLoadSwapEnabled() && getLoadName().equals(carLoads.getDefaultEmptyName())) { setLoadName(carLoads.getDefaultLoadName()); } else if (destTrack.isLoadSwapEnabled() && getLoadName().equals(carLoads.getDefaultLoadName())) { setLoadEmpty(); } else if (destTrack.isLoadEmptyEnabled() && getLoadName().equals(carLoads.getDefaultLoadName())) { setLoadEmpty(); } // empty car if it has a custom load else if (destTrack.isRemoveCustomLoadsEnabled() && !getLoadName().equals(carLoads.getDefaultEmptyName()) && !getLoadName().equals(carLoads.getDefaultLoadName())) { // remove this car's final destination if it has one setFinalDestination(null); setFinalDestinationTrack(null); // car arriving into staging with the RWE load? if (getLoadName().equals(getReturnWhenEmptyLoadName())) { setLoadName(carLoads.getDefaultEmptyName()); } else { setLoadEmpty(); // note that RWE sets the car's final destination } } } }