// Path: src/main/java/com/ccnode/codegenerator/exception/BizException.java
// public class BizException extends RuntimeException {
// 
//     public BizException(){
//     }
// 
//     public BizException(String s){
//         super(s);
//     }
// 
// }
// 
// Path: src/main/java/com/ccnode/codegenerator/exception/BizException.java
// public class BizException extends RuntimeException {
// 
//     public BizException(){
//     }
// 
//     public BizException(String s){
//         super(s);
//     }
// 
// }
// 
// Path: src/main/java/com/ccnode/codegenerator/pojoHelper/GenCodeResponseHelper.java
// public class GenCodeResponseHelper {
// 
//     private static GenCodeResponse response;
// 
//     public static void setResponse(GenCodeResponse response) {
//         GenCodeResponseHelper.response = response;
//     }
// 
//     public static GenCodeResponse getResponse() {
//         return response;
//     }
// 
//     public static GeneratedFile getByFileType(@NotNull OnePojoInfo onePojoInfo, FileType type, GenCodeResponse genCodeResponse){
//         String mapperSuffix = UserConfigService.removeStartAndEndSplitter(genCodeResponse.getUserConfigMap().get("mapper.suffix"));
//         String daoSuffix = UserConfigService.removeStartAndEndSplitter(genCodeResponse.getUserConfigMap().get("dao.suffix"));
//         String serviceSuffix = UserConfigService.removeStartAndEndSplitter(genCodeResponse.getUserConfigMap().get("service.suffix"));
//         String suffix = StringUtils.EMPTY;
//         switch (type){
//             case MAPPER:
//                 suffix = mapperSuffix == null ? GenCodeConfig.MAPPER_SUFFIX:mapperSuffix;
//                 break;
//             case DAO:
//                 suffix = daoSuffix == null ? GenCodeConfig.DAO_SUFFIX:daoSuffix;
//                 break;
//             case SERVICE:
//                 suffix = serviceSuffix == null ? GenCodeConfig.SERVICE_SUFFIX:serviceSuffix;
//                 break;
//         }
//         for (GeneratedFile generatedFile : onePojoInfo.getFiles()) {
//             if(type == FileType.NONE){
//                 continue;
//             }
//             if(generatedFile.getFileType().getCode().intValue() == type.getCode().intValue()
//                     && (suffix+generatedFile.getFileType().getSuffix()).equals(suffix+ type.getSuffix())){
//                 generatedFile.setSuffix(suffix);
//                 for (PojoFieldInfo fieldInfo:onePojoInfo.getPojoFieldInfos()) {
//                     if("id".equalsIgnoreCase(fieldInfo.getFieldName())){
//                         onePojoInfo.setIdType(fieldInfo.getFieldClass().getDesc());
//                         break;
//                     }
//                 }
//                 return generatedFile;
//             }
//         }
//         // todo
//         throw new RuntimeException("获取文件错误");
//     }
//     public static Boolean isUseGenericDao(GenCodeResponse response){
//         return getSwitch(response,"usegenericdao");
//     }
// 
//     public static Boolean getSwitch(GenCodeResponse response, String key){
//         return response != null && response.getUserConfigMap() != null && Objects.equal( response.getUserConfigMap().get(key),"true");
//     }
// 
//     public static String getProjectPathWithSplitter(GenCodeResponse response){
//         String projectPath = response.getRequest().getProjectPath();
//         if(StringUtils.isBlank(projectPath)){
//             throw new RuntimeException("error, projectPath is empty");
//         }
//                 if(!projectPath.endsWith(response.getPathSplitter())){
//                     projectPath += response.getPathSplitter();
//                 }
//         return projectPath;
//     }
// 
//     public static String getPathSplitter(){
//         return System.getProperty("file.separator");
//     }
//     @Nullable
//     public static String getSplitKey(GenCodeResponse response){
//         return response.getUserConfigMap().get("splitkey");
//     }
// 
// }


import com.ccnode.codegenerator.exception.BizException;
import com.ccnode.codegenerator.exception.BizException;
import com.ccnode.codegenerator.pojoHelper.GenCodeResponseHelper;
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.io.CharSink;
import com.google.common.io.Files;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
    public static <T> List<T> readLines(String fileName, LineProcessor<T> lineProcessor) throws IOException {
        File file = new File(fileName);
        Preconditions.checkNotNull(file);
        Preconditions.checkState(file.isFile());
        return readLines(file, lineProcessor);
    }

    public static  void writeLines(String fileName,List<String> list) throws IOException {
        writeLines(fileName, list, DEFAULT_CHARSET);
    }
    public static  void writeLines(String fileName,List<String> list,Charset charset) throws IOException {
        CharSink cs = Files.asCharSink(new File(fileName), charset);
        list = PojoUtil.avoidEmptyList(list);
        cs.writeLines(list);
    }

    public static  void writeLines(File file,List<String> list) throws IOException {
        writeLines(file, list, DEFAULT_CHARSET);
    }
    public static  void writeLines(File file,List<String> list,Charset charset) throws IOException {
        CharSink cs = Files.asCharSink(file, charset);
        list = PojoUtil.avoidEmptyList(list);
        cs.writeLines(list);
    }



    @Nullable
    public static File matchOnlyOneFile(String directory, String subFileName){
        List<File> allSubFiles = IOUtils.getAllSubFiles(directory);
// Path: src/main/java/com/ccnode/codegenerator/exception/BizException.java
// public class BizException extends RuntimeException {
// 
//     public BizException(){
//     }
// 
//     public BizException(String s){
//         super(s);
//     }
// 
// }
// 
// Path: src/main/java/com/ccnode/codegenerator/exception/BizException.java
// public class BizException extends RuntimeException {
// 
//     public BizException(){
//     }
// 
//     public BizException(String s){
//         super(s);
//     }
// 
// }
// 
// Path: src/main/java/com/ccnode/codegenerator/pojoHelper/GenCodeResponseHelper.java
// public class GenCodeResponseHelper {
// 
//     private static GenCodeResponse response;
// 
//     public static void setResponse(GenCodeResponse response) {
//         GenCodeResponseHelper.response = response;
//     }
// 
//     public static GenCodeResponse getResponse() {
//         return response;
//     }
// 
//     public static GeneratedFile getByFileType(@NotNull OnePojoInfo onePojoInfo, FileType type, GenCodeResponse genCodeResponse){
//         String mapperSuffix = UserConfigService.removeStartAndEndSplitter(genCodeResponse.getUserConfigMap().get("mapper.suffix"));
//         String daoSuffix = UserConfigService.removeStartAndEndSplitter(genCodeResponse.getUserConfigMap().get("dao.suffix"));
//         String serviceSuffix = UserConfigService.removeStartAndEndSplitter(genCodeResponse.getUserConfigMap().get("service.suffix"));
//         String suffix = StringUtils.EMPTY;
//         switch (type){
//             case MAPPER:
//                 suffix = mapperSuffix == null ? GenCodeConfig.MAPPER_SUFFIX:mapperSuffix;
//                 break;
//             case DAO:
//                 suffix = daoSuffix == null ? GenCodeConfig.DAO_SUFFIX:daoSuffix;
//                 break;
//             case SERVICE:
//                 suffix = serviceSuffix == null ? GenCodeConfig.SERVICE_SUFFIX:serviceSuffix;
//                 break;
//         }
//         for (GeneratedFile generatedFile : onePojoInfo.getFiles()) {
//             if(type == FileType.NONE){
//                 continue;
//             }
//             if(generatedFile.getFileType().getCode().intValue() == type.getCode().intValue()
//                     && (suffix+generatedFile.getFileType().getSuffix()).equals(suffix+ type.getSuffix())){
//                 generatedFile.setSuffix(suffix);
//                 for (PojoFieldInfo fieldInfo:onePojoInfo.getPojoFieldInfos()) {
//                     if("id".equalsIgnoreCase(fieldInfo.getFieldName())){
//                         onePojoInfo.setIdType(fieldInfo.getFieldClass().getDesc());
//                         break;
//                     }
//                 }
//                 return generatedFile;
//             }
//         }
//         // todo
//         throw new RuntimeException("获取文件错误");
//     }
//     public static Boolean isUseGenericDao(GenCodeResponse response){
//         return getSwitch(response,"usegenericdao");
//     }
// 
//     public static Boolean getSwitch(GenCodeResponse response, String key){
//         return response != null && response.getUserConfigMap() != null && Objects.equal( response.getUserConfigMap().get(key),"true");
//     }
// 
//     public static String getProjectPathWithSplitter(GenCodeResponse response){
//         String projectPath = response.getRequest().getProjectPath();
//         if(StringUtils.isBlank(projectPath)){
//             throw new RuntimeException("error, projectPath is empty");
//         }
//                 if(!projectPath.endsWith(response.getPathSplitter())){
//                     projectPath += response.getPathSplitter();
//                 }
//         return projectPath;
//     }
// 
//     public static String getPathSplitter(){
//         return System.getProperty("file.separator");
//     }
//     @Nullable
//     public static String getSplitKey(GenCodeResponse response){
//         return response.getUserConfigMap().get("splitkey");
//     }
// 
// }


// Path: src/main/java/com/ccnode/codegenerator/util/IOUtils.java
import com.ccnode.codegenerator.exception.BizException;
import com.ccnode.codegenerator.exception.BizException;
import com.ccnode.codegenerator.pojoHelper.GenCodeResponseHelper;
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.io.CharSink;
import com.google.common.io.Files;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

    public static <T> List<T> readLines(String fileName, LineProcessor<T> lineProcessor) throws IOException {
        File file = new File(fileName);
        Preconditions.checkNotNull(file);
        Preconditions.checkState(file.isFile());
        return readLines(file, lineProcessor);
    }

    public static  void writeLines(String fileName,List<String> list) throws IOException {
        writeLines(fileName, list, DEFAULT_CHARSET);
    }
    public static  void writeLines(String fileName,List<String> list,Charset charset) throws IOException {
        CharSink cs = Files.asCharSink(new File(fileName), charset);
        list = PojoUtil.avoidEmptyList(list);
        cs.writeLines(list);
    }

    public static  void writeLines(File file,List<String> list) throws IOException {
        writeLines(file, list, DEFAULT_CHARSET);
    }
    public static  void writeLines(File file,List<String> list,Charset charset) throws IOException {
        CharSink cs = Files.asCharSink(file, charset);
        list = PojoUtil.avoidEmptyList(list);
        cs.writeLines(list);
    }



    @Nullable
    public static File matchOnlyOneFile(String directory, String subFileName){
        List<File> allSubFiles = IOUtils.getAllSubFiles(directory);
        if(!subFileName.startsWith(GenCodeResponseHelper.getPathSplitter())){