// Path: QuickProject-Util/src/main/java/chanedi/enums/DBDialectType.java
// public enum DBDialectType {
// 
//     MYSQL("mysql"), ORACLE("oracle"), H2("h2");
// 
//     private String type;
// 
//     private DBDialectType(String type) {
//         this.type = type;
//     }
// 
//     @Override
//     public String toString() {
//         return type;
//     }
// 
// }
// 
// Path: QuickProject-Generator/src/main/java/chanedi/generator/file/exception/ConfigException.java
// public class ConfigException extends Exception {
// 
//     public ConfigException() {
//     }
// 
//     public ConfigException(String message) {
//         super(message);
//     }
// 
//     public ConfigException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ConfigException(Throwable cause) {
//         super(cause);
//     }
// 
// }
// 
// Path: QuickProject-Generator/src/main/java/chanedi/generator/model/PropertyType.java
// public class PropertyType extends HashMap {
// 
//     public PropertyType(String javaType) {
//         super();
//         addType("java", javaType);
//     }
// 
//     public void addType(String typeKey, String type) {
//         put(typeKey, type);
//     }
// 
// }
// 
// Path: QuickProject-Util/src/main/java/chanedi/util/PropertiesWithOrder.java
// public class PropertiesWithOrder extends Properties {
// 
//     private List<Object> keyList = new ArrayList<Object>();
// 
//     @Override
//     public synchronized Object put(Object key, Object value) {
//         if (!keyList.contains(key)) {
//             keyList.add(key);
//         }
//         return super.put(key, value);
//     }
// 
//     /**
//      * 返回key值，该key值顺序与文件中的顺序相同。
//      * @return
//      */
//     public List<Object> keysInOrder() {
//         return keyList;
//     }
// 
// }


import chanedi.enums.DBDialectType;
import chanedi.generator.file.exception.ConfigException;
import chanedi.generator.model.PropertyType;
import chanedi.util.PropertiesWithOrder;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.annotation.concurrent.NotThreadSafe;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
package chanedi.generator.file;



/**
 * 单例。
 * @author Chanedi
 */
@NotThreadSafe
public final class PropertyTypeContext {

    private Logger logger = LoggerFactory.getLogger(getClass());
    private static PropertyTypeContext instance;

    private static final String DB_CONVERT_FILE_NAME = "dbToJava_";
    private static final String TYPE_DEF_FILE_NAME = "typeDefinition";
    private static final String CONFIG_FILE_SUFFIX = ".properties";
    private String typeMatchConfigPath = "classpath:/typeMatch/";
    private Map<String, PropertyType> propertyTypes = new HashMap<String, PropertyType>(); // key 为 javaType
    private PropertiesWithOrder dbConvertProp = new PropertiesWithOrder();

    private ResourceLoader resourceLoader = new PathMatchingResourcePatternResolver();

    private PropertyTypeContext() throws ConfigException {
        super();
        GlobalConfig globalConfig = GlobalConfig.getInstance();

// Path: QuickProject-Util/src/main/java/chanedi/enums/DBDialectType.java
// public enum DBDialectType {
// 
//     MYSQL("mysql"), ORACLE("oracle"), H2("h2");
// 
//     private String type;
// 
//     private DBDialectType(String type) {
//         this.type = type;
//     }
// 
//     @Override
//     public String toString() {
//         return type;
//     }
// 
// }
// 
// Path: QuickProject-Generator/src/main/java/chanedi/generator/file/exception/ConfigException.java
// public class ConfigException extends Exception {
// 
//     public ConfigException() {
//     }
// 
//     public ConfigException(String message) {
//         super(message);
//     }
// 
//     public ConfigException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ConfigException(Throwable cause) {
//         super(cause);
//     }
// 
// }
// 
// Path: QuickProject-Generator/src/main/java/chanedi/generator/model/PropertyType.java
// public class PropertyType extends HashMap {
// 
//     public PropertyType(String javaType) {
//         super();
//         addType("java", javaType);
//     }
// 
//     public void addType(String typeKey, String type) {
//         put(typeKey, type);
//     }
// 
// }
// 
// Path: QuickProject-Util/src/main/java/chanedi/util/PropertiesWithOrder.java
// public class PropertiesWithOrder extends Properties {
// 
//     private List<Object> keyList = new ArrayList<Object>();
// 
//     @Override
//     public synchronized Object put(Object key, Object value) {
//         if (!keyList.contains(key)) {
//             keyList.add(key);
//         }
//         return super.put(key, value);
//     }
// 
//     /**
//      * 返回key值，该key值顺序与文件中的顺序相同。
//      * @return
//      */
//     public List<Object> keysInOrder() {
//         return keyList;
//     }
// 
// }


// Path: QuickProject-Generator/src/main/java/chanedi/generator/file/PropertyTypeContext.java
import chanedi.enums.DBDialectType;
import chanedi.generator.file.exception.ConfigException;
import chanedi.generator.model.PropertyType;
import chanedi.util.PropertiesWithOrder;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.annotation.concurrent.NotThreadSafe;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

package chanedi.generator.file;



/**
 * 单例。
 * @author Chanedi
 */
@NotThreadSafe
public final class PropertyTypeContext {

    private Logger logger = LoggerFactory.getLogger(getClass());
    private static PropertyTypeContext instance;

    private static final String DB_CONVERT_FILE_NAME = "dbToJava_";
    private static final String TYPE_DEF_FILE_NAME = "typeDefinition";
    private static final String CONFIG_FILE_SUFFIX = ".properties";
    private String typeMatchConfigPath = "classpath:/typeMatch/";
    private Map<String, PropertyType> propertyTypes = new HashMap<String, PropertyType>(); // key 为 javaType
    private PropertiesWithOrder dbConvertProp = new PropertiesWithOrder();

    private ResourceLoader resourceLoader = new PathMatchingResourcePatternResolver();

    private PropertyTypeContext() throws ConfigException {
        super();
        GlobalConfig globalConfig = GlobalConfig.getInstance();

        DBDialectType dialect = globalConfig.getDbDialectType();