public ExpectedHandlingEvent expectedEventAfterUnloadAt( Location lastUnloadLocation )
{
// After UNLOAD, expect LOAD location and voyage of following itinerary leg, or CLAIM if no more legs
for( Iterator<Leg> it = itinerary.legs().get().iterator(); it.hasNext(); )
{
final Leg leg = it.next();
if( leg.unloadLocation().get().equals( lastUnloadLocation ) )
{
// Cargo has a matching unload location in itinerary
if( it.hasNext() )
{
// Cargo has not arrived yet (uncompleted legs in itinerary)
// We expect it to be loaded onto some Carrier
final Leg nextLeg = it.next();
return buildEvent( HandlingEventType.LOAD, nextLeg.loadLocation().get(), nextLeg.loadTime()
.get(), nextLeg.voyage().get() );
}
else
{
// Cargo has arrived (no more legs in itinerary)
// We expect it to be claimed by the customer