class MultiHostgroupDownscaleFlowEventChainFactory implements FlowEventChainFactory<MultiHostgroupClusterAndStackDownscaleTriggerEvent> {

    @Override
    public Queue<Selectable> createFlowTriggerEventQueue(MultiHostgroupClusterAndStackDownscaleTriggerEvent event) {
        Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
        for (Entry<String, Set<Long>> entry : event.getInstanceIdsByHostgroupMap().entrySet()) {
            ClusterScaleTriggerEvent cste;
            cste = new ClusterDownscaleTriggerEvent(DECOMMISSION_EVENT.event(), event.getResourceId(), entry.getKey(), entry.getValue(), event.accepted(),
                    event.getDetails());
            flowEventChain.add(cste);
            if (event.getScalingType() == ScalingType.DOWNSCALE_TOGETHER) {
                StackScaleTriggerEvent sste;
                sste = new StackDownscaleTriggerEvent(STACK_DOWNSCALE_EVENT.event(), event.getResourceId(), entry.getKey(), entry.getValue());
                flowEventChain.add(sste);
            }
        }
        return flowEventChain;
    }

}