class GatewayRuleConverter {

    static ParamFlowRule applyToParamRule(/*@Valid*/ GatewayFlowRule gatewayRule, int idx) {
        ParamFlowRule paramRule = new ParamFlowRule(gatewayRule.getResource())
            .setCount(gatewayRule.getCount())
            .setGrade(gatewayRule.getGrade())
            .setDurationInSec(gatewayRule.getIntervalSec())
            .setBurstCount(gatewayRule.getBurst())
            .setControlBehavior(gatewayRule.getControlBehavior())
            .setMaxQueueingTimeMs(gatewayRule.getMaxQueueingTimeoutMs())
            .setParamIdx(idx);
        GatewayParamFlowItem gatewayItem = gatewayRule.getParamItem();
        // Apply the current idx to gateway rule item.
        gatewayItem.setIndex(idx);
        // Apply for pattern-based parameters.
        String valuePattern = gatewayItem.getPattern();
        if (valuePattern != null) {
            paramRule.getParamFlowItemList().add(generateNonMatchPassParamItem());
        }
        return paramRule;
    }

    private  GatewayRuleConverter();

}