class QueueingStrategyFactory {

    public static QueueingStrategy buildQueueStrategy(JsonObject hookConfiguration) {
        QueueingStrategy queueingStrategy = new DefaultQueueingStrategy();
        if(hookConfiguration == null || !hookConfiguration.containsKey(QUEUEING_STRATEGY_PROPERTY)){
            return queueingStrategy;
        }

        Object queueingStrategyConfigObj = hookConfiguration.getValue(QUEUEING_STRATEGY_PROPERTY);
        if(!(queueingStrategyConfigObj instanceof JsonObject)){
            LOG.warn("Invalid 'queueingStrategy' configuration found: " + queueingStrategyConfigObj + ". Using DefaultQueueingStrategy instead");
            return queueingStrategy;
        }

        JsonObject queueingStrategyConfig = (JsonObject) queueingStrategyConfigObj;
        Strategy strategy = Strategy.fromString(queueingStrategyConfig.getString("type"));

        if(strategy == null){
            LOG.warn("Invalid 'queueingStrategy' configuration found: " + queueingStrategyConfig.encode() + ". Using DefaultQueueingStrategy instead");
            return queueingStrategy;
        }

        switch (strategy){
            case DISCARD_PAYLOAD:
                queueingStrategy = new DiscardPayloadQueueingStrategy();
                break;
            case REDUCED_PROPAGATION:
                queueingStrategy = buildReducedPropagationQueueingStrategy(queueingStrategyConfig);
                break;
            default:
            LOG.warn("Unknown strategy '"+strategy+"'. Using DefaultQueueingStrategy instead");
        }

        return queueingStrategy;
    }

    private  QueueingStrategyFactory();

}