class ImportStrategyAccumulator {

    public ImportStrategyAccumulator partitionEvents( List<Event> events, ImportStrategy importStrategy,
        Map<String, ProgramStageInstance> existingEvents )
    {
        if ( importStrategy.isCreate() )
        {
            create.addAll( events );
        }
        else if ( importStrategy.isCreateAndUpdate() )
        {
            for ( Event event : events )
            {
                sortCreatesAndUpdates( event, create, update, existingEvents );
            }
        }
        else if ( importStrategy.isUpdate() )
        {
            update.addAll( events );
        }
        else if ( importStrategy.isDelete() )
        {
            final Set<String> existingEventKeys = existingEvents.keySet();
            delete.addAll( events.stream()
                .filter( event -> existingEventKeys.contains( event.getUid() ) )
                .collect( Collectors.toSet() ) );
        }
        else if ( importStrategy.isSync() )
        {
            for ( Event event : events )
            {
                if ( event.isDeleted() )
                {
                    delete.add( event );
                }
                else
                {
                    sortCreatesAndUpdates( event, create, update, existingEvents );
                }
            }
        }
        return this;
    }

}