private List<Event> toEvents(Collection<Item> items) {
        if (items.isEmpty()) {
            return ImmutableList.of();
        }

        // Sort the items to match the order of their events in an attempt to get first-in-first-out.
        return items.stream().sorted().map(Item::toEvent).collect(Collectors.toList());
    }
private List < Event > toEvents ( Collection < Item > items ) { if ( items . isEmpty ( ) ) { return ImmutableList . of ( ) ; } return items . stream ( ) . sorted ( ) . map ( Item :: toEvent ) . collect ( Collectors . toList ( ) ) ; }
Converts a collection of Items to Events.