Class CommonConfig
java.lang.Object
com.github.theword.queqiao.tool.config.CommonConfig
- Direct Known Subclasses:
Config
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckFileExists(Path path, String fileName) 检查配置文件是否存在org.slf4j.Loggerprotected abstract voidloadConfigValues(Map<String, Object> configMap) 加载配置文件内容protected StringnormalizeKeyPath(String keyPath) 规范化键路径。protected voidreadConfigFile(String configFolder, String fileName) 读取配置文件readConfigMap(Path path, String fileName) 读取整个配置文件为 Map。protected ObjectreadConfigValue(Path path, String fileName, String keyPath) 按键路径读取配置项。protected voidreadConfigValues(Path path, String fileName) 读取配置文件内容protected voidsynchronizeConfigFile(Path path, String fileName) 严格同步字段:protected boolean写入整个配置文件。protected booleanwriteConfigValue(Path path, String fileName, String keyPath, Object value) 按键路径写入配置项。
-
Constructor Details
-
CommonConfig
public CommonConfig(org.slf4j.Logger logger)
-
-
Method Details
-
getLogger
public org.slf4j.Logger getLogger() -
readConfigFile
读取配置文件- Parameters:
configFolder- 配置文件所在目录fileName- 配置文件名
-
readConfigValues
读取配置文件内容- Parameters:
path- 路径fileName- 文件名
-
loadConfigValues
加载配置文件内容由原版端实现,读取自定义 regex.yml
- Parameters:
configMap- 配置文件内容
-
checkFileExists
检查配置文件是否存在- Parameters:
path- 路径fileName- 文件名
-
synchronizeConfigFile
严格同步字段:1. 当前缺少默认字段 -> 补默认值
2. 当前多出未知字段 -> 删除
3. 类型不匹配 -> 回退默认值
-
readConfigMap
读取整个配置文件为 Map。- Parameters:
path- 配置文件路径fileName- 配置文件名- Returns:
- 配置内容(若读取失败则返回空 Map)
-
readConfigValue
按键路径读取配置项。键路径使用 "." 分隔,例如:websocket_server.port。
- Parameters:
path- 配置文件路径fileName- 配置文件名keyPath- 键路径- Returns:
- 配置值,不存在时返回 null
-
writeConfigMap
写入整个配置文件。- Parameters:
path- 配置文件路径fileName- 配置文件名configMap- 配置内容- Returns:
- 是否写入成功
-
writeConfigValue
按键路径写入配置项。键路径使用 "." 分隔,例如:websocket_server.port。
- Parameters:
path- 配置文件路径fileName- 配置文件名keyPath- 键路径value- 键值- Returns:
- 是否写入成功
-
normalizeKeyPath
规范化键路径。会去除首尾空白、空段,示例:".a..b. " -> "a.b"
-