All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.javaoffers.brief.modelhelper.parse.ModelParseUtils Maven / Gradle / Ivy

There is a newer version: 3.6.8
Show newest version
package com.javaoffers.brief.modelhelper.parse;

import com.javaoffers.brief.modelhelper.jdbc.ResultSetExecutor;
import com.javaoffers.brief.modelhelper.utils.Lists;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Auther: create by cmj on 2021/12/7 20:01
 */
public class ModelParseUtils {

    static final int batch = 100;

    static final ModelParse modelParse = new SmartModelParse();

    static final RealtimeModelParse realtimeSmartModelParse = new RealtimeSmartModelParse();

    public static  List converterMap2Model(Class clazz, List> listMap) {
        if (listMap.size() > batch){
            List>> partition = Lists.partition(listMap, batch);
            List[] slot = new List[partition.size()];
            ArrayList resutl = new ArrayList<>();
            partition.parallelStream().forEach(list->{
                slot[list.getPartitionIndex()] = modelParse.converterMap2Model(clazz, list.getList()) ;
            });
            Arrays.stream(slot).forEach(resutl::addAll);
            return resutl;
        }else{
            return modelParse.converterMap2Model(clazz, listMap);
        }

    }

    public static  List  converterResultSet2ModelForJoinSelect(Class clazz, ResultSetExecutor rs) {
        return realtimeSmartModelParse.converterResultSet2ModelForJoinSelect(clazz, rs);
    }

    public static  List converterResultSet2ModelForNormalSelect(Class modelClass, ResultSetExecutor briefResultSetExecutor) {
        return realtimeSmartModelParse.converterResultSet2ModelForNormalSelect(modelClass, briefResultSetExecutor);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy