class GroupHintParser {

    public static GroupIndex convertHint2Index(String sql) {
        String groupIndexHint = extractTDDLGroupHint(sql);
        if (null != groupIndexHint && !groupIndexHint.equals("")) {
            String[] hintWithRetry = groupIndexHint.split(",");
            if (hintWithRetry.length == 1) {
                int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]);
                return new GroupIndex(index, false);
            } else if (hintWithRetry.length == 2) {
                int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]);
                boolean retry = GroupHintParser.getFailRetryFromHintPiece(hintWithRetry[1]);
                return new GroupIndex(index, retry);
            } else {
                throw new IllegalArgumentException("the standard group hint is:'groupIndex:12[,failRetry:true]'"
                                                   + ",current hint is:" + groupIndexHint);
            }
        } else {
            return null;
        }
    }

}