1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 10:38:19 +08:00

Compare commits

...

45 Commits

Author SHA1 Message Date
dependabot[bot] 89ab06a0d9 build(deps): bump kotlin.version from 2.3.21 to 2.4.0
Bumps `kotlin.version` from 2.3.21 to 2.4.0.

Updates `org.jetbrains.kotlin:kotlin-stdlib-jdk8` from 2.3.21 to 2.4.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v2.3.21...v2.4.0)

Updates `org.jetbrains.kotlin:kotlin-maven-plugin` from 2.3.21 to 2.4.0

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8
  dependency-version: 2.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin
  dependency-version: 2.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-04 02:02:22 +00:00
renovate[bot] 85266283c4 fix(deps): update dependency com.typesafe:config to v1.4.9 (#243)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-03 23:54:59 +00:00
renovate[bot] b0a9f6505c fix(deps): update dependency org.mongodb:mongodb-driver-sync to v5.8.0 (#241)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-29 02:01:07 +00:00
renovate[bot] 8c40eb20ea chore(deps): update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.5.6 (#240)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-28 00:33:52 +00:00
renovate[bot] 25ff7ab350 fix(deps): update dependency org.mongodb:mongodb-driver-sync to v5.7.1 (#238)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-27 17:17:07 +00:00
renovate[bot] ad90251596 chore(deps): update log4j2 monorepo to v2.26.0 (#236)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-07 14:42:19 +00:00
renovate[bot] ed05374054 fix(deps): update dependency com.typesafe:config to v1.4.8 (#234)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-05 14:36:51 +00:00
renovate[bot] b5681f2412 fix(deps): update dependency org.mongodb:mongodb-driver-sync to v5.7.0 (#233)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-01 01:59:52 +00:00
renovate[bot] bd9923ab7e fix(deps): update dependency com.typesafe:config to v1.4.7 (#231)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-28 15:14:18 +00:00
renovate[bot] 9dece6004e fix(deps): update dependency com.google.code.gson:gson to v2.14.0 (#230)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-24 00:34:46 +00:00
renovate[bot] 654782afe1 fix(deps): update kotlin monorepo to v2.3.21 (#223)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-23 14:42:12 +00:00
renovate[bot] 903f0239b2 fix(deps): update dependency org.mongodb:mongodb-driver-sync to v5.6.5 (#228)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-09 13:37:56 +00:00
renovate[bot] dda929c0a9 chore(deps): update log4j2 monorepo to v2.25.4 (#227)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-28 16:53:33 +00:00
renovate[bot] 2482048449 chore(deps): update dependency org.jetbrains.dokka:dokka-maven-plugin to v2.2.0 (#225)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-26 14:33:40 +00:00
carm f54ee83938 feat(holder): Add file type multi configuration. #169 2026-03-11 11:24:27 +08:00
carm f5316eb320 feat(holder): Add file type multi configuration. #169 2026-03-11 11:16:19 +08:00
carm 500eebefde feat(holder): Try to support MultiConfiguration. #169 2026-03-11 11:02:11 +08:00
renovate[bot] d9cb95b2e9 chore(deps): update actions/upload-artifact action to v7 2026-03-10 08:05:30 +08:00
renovate[bot] ce6554c3f1 chore(deps): update dependency org.apache.maven.plugins:maven-shade-plugin to v3.6.2 (#221)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-05 14:36:14 +00:00
renovate[bot] 7dcd690a05 fix(deps): update dependency org.yaml:snakeyaml to v2.6 (#219)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-27 01:25:07 +00:00
renovate[bot] f376f22ad0 fix(deps): update dependency com.typesafe:config to v1.4.6 (#218)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-24 19:45:53 +00:00
renovate[bot] ab586c4b00 fix(deps): update dependency org.mongodb:mongodb-driver-sync to v5.6.4 (#216)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-23 12:44:42 +00:00
renovate[bot] 64cbfaa974 chore(deps): update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.5.5 (#215)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-21 17:50:54 +00:00
dependabot[bot] 3cab343919 build(deps): bump kotlin.version from 2.3.0 to 2.3.10
Bumps `kotlin.version` from 2.3.0 to 2.3.10.

Updates `org.jetbrains.kotlin:kotlin-stdlib-jdk8` from 2.3.0 to 2.3.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v2.3.0...v2.3.10)

Updates `org.jetbrains.kotlin:kotlin-maven-plugin` from 2.3.0 to 2.3.10

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8
  dependency-version: 2.3.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin
  dependency-version: 2.3.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-21 00:56:59 +08:00
renovate[bot] 1ad8c1f407 chore(deps): update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.15.0 (#207)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-19 00:58:38 +00:00
renovate[bot] 4e6db50049 fix(deps): update dependency org.mongodb:mongodb-driver-sync to v5.6.3 (#209)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-18 22:45:39 +00:00
renovate[bot] e62cef5644 fix(deps): update dependency org.jetbrains:annotations to v26.1.0 (#214)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-18 18:56:13 +00:00
dependabot[bot] d6a56003aa build(deps): bump org.sonatype.central:central-publishing-maven-plugin
Bumps [org.sonatype.central:central-publishing-maven-plugin](https://github.com/sonatype/central-publishing-maven-plugin) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/sonatype/central-publishing-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: org.sonatype.central:central-publishing-maven-plugin
  dependency-version: 0.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-31 02:46:18 +08:00
renovate[bot] 8a5870300d chore(deps): update actions/upload-artifact action to v6 2025-12-29 08:50:26 +08:00
dependabot[bot] 42885b2a12 build(deps): bump kotlin.version from 2.2.21 to 2.3.0
Bumps `kotlin.version` from 2.2.21 to 2.3.0.

Updates `org.jetbrains.kotlin:kotlin-stdlib-jdk8` from 2.2.21 to 2.3.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v2.3.0/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v2.2.21...v2.3.0)

Updates `org.jetbrains.kotlin:kotlin-maven-plugin` from 2.2.21 to 2.3.0

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8
  dependency-version: 2.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin
  dependency-version: 2.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-29 08:50:04 +08:00
renovate[bot] 96216d5126 chore(deps): update log4j2 monorepo to v2.25.3 (#204)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-16 21:58:48 +00:00
renovate[bot] d890ce1b94 chore(deps): update dependency org.apache.maven.plugins:maven-release-plugin to v3.3.1 (#201)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-13 14:29:02 +00:00
renovate[bot] d1ff4f7014 fix(deps): update dependency org.mongodb:mongodb-driver-sync to v5.6.2 (#199)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-08 21:33:41 +00:00
renovate[bot] 9f3089566c chore(deps): update dependency org.apache.maven.plugins:maven-release-plugin to v3.3.0 (#198)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-03 20:54:54 +00:00
renovate[bot] 79105bf400 chore(deps): update actions/checkout action to v6 2025-12-01 09:31:45 +08:00
renovate[bot] 2b0b74af92 chore(deps): update dependency org.apache.maven.plugins:maven-source-plugin to v3.4.0 (#197)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-29 05:37:12 +00:00
renovate[bot] c65d164167 chore(deps): update dependency org.apache.maven.plugins:maven-jar-plugin to v3.5.0 (#195)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-15 17:30:30 +00:00
renovate[bot] 74bde0c7ea chore(deps): update dependency org.apache.maven.plugins:maven-release-plugin to v3.2.0 (#194)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-09 00:57:07 +00:00
carm 7fba61cb64 docs: Use english version issues templates. 2025-11-06 03:07:02 +08:00
renovate[bot] b609e1d174 chore(deps): update actions/upload-artifact action to v5 2025-10-30 10:54:38 +08:00
renovate[bot] bdbd484690 fix(deps): update kotlin monorepo to v2.2.21 (#191)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-23 14:08:33 +00:00
renovate[bot] cc5383b0f2 chore(deps): update github/codeql-action action to v4 2025-10-23 10:37:05 +08:00
renovate[bot] 35d2653f56 chore(deps): update dependency org.jetbrains.dokka:dokka-maven-plugin to v2.1.0 (#190)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-15 18:54:14 +00:00
carm d6fa7710dc fix: Try to ignore errors when applying replacer 2025-10-09 02:58:21 +08:00
renovate[bot] fdb6d81bf0 fix(deps): update dependency org.mongodb:mongodb-driver-sync to v5.6.1 (#186)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-06 14:26:30 +00:00
30 changed files with 489 additions and 129 deletions
+20 -56
View File
@@ -1,70 +1,34 @@
---
name:
问题提交
about:
描述问题并提交,帮助我们对其进行检查与修复。
title: ''
labels:
bug
name: Submit bugs&issues
about: Describe the problem and submit it to help us review and fix it.
title: 'fix: '
labels: bug
assignees: ''
---
###
*
*问题简述
**
### **Description**
用简短的话语描述一下大概问题。
<!-- Describe the general problem in short words.-->
###
*
*问题来源
**
### **Operations**
描述一下通过哪些操作才发现的问题,如:
<!--
Describe the problem discovered through what operations, such as:
1.
使用了 '...'
2.
输入了 '....'
3.
出现了报错 '....'
1. Clicked '...'
2. Typed '....'
3. Error says '....'
-->
###
*
*预期结果
** (可选)
### **Expected result** _(Optional)_
如果问题不发生,应该是什么情况
### **Screenshots & Error Logs**
###
*
*问题截图/问题报错
**
### **Environment**
如果有报错或输出,请提供截图。
- System: `Windows 10` / `Ubuntu` / `...`
- Java version: `JDK11` / `OPENJDK8` / `JRE8` / `...`
###
*
*操作环境
**
### **Anything else...**
-
系统环境:
`Windows 10` /
`Ubuntu` /
`...`
-
Java版本:
`JDK11` /
`OPENJDK8` /
`JRE8` /
`...`
###
*
*其他补充
**
如有其他补充,可以在这里描述。
<!-- If there are other supplements, they can be described here. -->
+12 -27
View File
@@ -1,38 +1,23 @@
---
name:
功能需求
about:
希望我们提供更多的功能。
title: ''
labels:
enhancement
name: Features
about: Ask for new features.
title: 'feat: '
labels: enhancement
assignees: ''
---
###
*
*功能简述
**
### **Description**
简单的描述一下你想要的功能
<!-- Describe the features in short words.-->
###
*
*需求来源
**
### **Source**
简单的描述一下为什么需要这个功能。
<!-- Describe the reason that you need this feature in short words.-->
###
*
*功能参考
**(可选)
### **Examples** _(Optional)_
如果有相关功能的参考,如文本、截图,请提供给我们。
<!--Any screenshots or example codes please.-->
###
*
*附加内容
**
### **Additional details**
如果有什么小细节需要重点注意,请在这里告诉我们。
<!--If there are any small details that need to be highlighted, please let us know here.-->
+4 -4
View File
@@ -38,11 +38,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v6
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@v4
# ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4
+2 -2
View File
@@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: "Set up JDK"
uses: actions/setup-java@v5
with:
@@ -87,7 +87,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: "Set up JDK"
uses: actions/setup-java@v5
with:
+2 -2
View File
@@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: "Set up JDK"
uses: actions/setup-java@v5
with:
@@ -26,7 +26,7 @@ jobs:
- name: "Target Stage"
run: mkdir staging && cp */target/*.jar staging
- name: "Upload artifact"
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: Artifact
path: staging
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>configured-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>4.2.0</version>
<version>4.2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>configured-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>4.2.0</version>
<version>4.2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
@@ -17,7 +17,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
<deps.mysql-driver.version>8.0.33</deps.mysql-driver.version>
<log4j.version>2.25.2</log4j.version>
<log4j.version>2.26.0</log4j.version>
</properties>
<artifactId>configured-demo</artifactId>
<packaging>jar</packaging>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
+3 -3
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
@@ -14,7 +14,7 @@
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<kotlin.version>2.2.20</kotlin.version>
<kotlin.version>2.4.0</kotlin.version>
</properties>
<artifactId>configured-feature-kotlin</artifactId>
@@ -86,7 +86,7 @@
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>2.0.0</version>
<version>2.2.0</version>
<executions>
<execution>
<phase>pre-site</phase>
+70
View File
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<kotlin.version>2.3.10</kotlin.version>
</properties>
<artifactId>configured-feature-multi</artifactId>
<packaging>jar</packaging>
<name>Configured - Record Feature</name>
<url>https://github.com/CarmJos/configured</url>
<description>Provides Java record type support for the Configured framework.</description>
<dependencies>
<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-feature-file</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-yaml</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,135 @@
package cc.carm.lib.configuration.multi;
import cc.carm.lib.configuration.source.ConfigurationHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public abstract class MultiConfiguration<K, T> {
protected final ConcurrentHashMap<K, T> valuesCache = new ConcurrentHashMap<>();
public MultiConfiguration() {
}
/**
* Read the value of the key from the holder, and return the value.
*
* @param key The key of the value to read.
* @param holder The holder of the value to read.
* @return The value of the key, or null if the value is not exist.
*/
public abstract T read(@NotNull K key, @NotNull ConfigurationHolder<?> holder);
/**
* Write (and save) the value of the key to the holder, then update the cache.
*
* @param holder The holder of the value to write.
* @param value The value to write, which should not be null.
*/
public abstract void write(@NotNull ConfigurationHolder<?> holder, @NotNull T value);
/**
* Get all holders of the configuration, which should be a concurrent map to support concurrent access.
*
* @return All holders of the configuration.
*/
public abstract @NotNull Map<K, ConfigurationHolder<?>> holders();
/**
* Get the holder of the key.
* If the holder of the key is not exist,
* it should be created then return the created holder.
*
* @param key The key of the holder to get.
* @return The holder of the key.
*/
public abstract @NotNull ConfigurationHolder<?> holder(@NotNull K key);
/**
* Remove the holder of the key, and remove the value of the key from the cache.
* Also delete the configuration file if necessary.
*
* @param key The key of the holder to remove.
*/
public abstract void removeHolder(@NotNull K key);
public void loadAll() {
for (Map.Entry<K, ConfigurationHolder<?>> entry : holders().entrySet()) {
K key = entry.getKey();
ConfigurationHolder<?> holder = entry.getValue();
try {
T loaded = read(key, holder);
if (loaded != null) {
valuesCache.put(key, loaded);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public void saveAll() {
for (Map.Entry<K, T> entry : valuesCache.entrySet()) {
K key = entry.getKey();
T value = entry.getValue();
ConfigurationHolder<?> holder = holder(key);
try {
write(holder, value);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
/**
* Get all keys in the cache.
*
* @return All keys in the cache.
*/
public @NotNull Set<K> keys() {
return valuesCache.keySet();
}
/**
* Get all values in the cache.
*
* @return All values in the cache.
*/
public @NotNull Map<K, T> values() {
return this.valuesCache;
}
/**
* Get the value of the key, or null if the value is not exist.
*
* @param key The key of the value to get.
* @return The value of the key, or null if the value is not exist.
*/
public @Nullable T get(@NotNull K key) {
return valuesCache.get(key);
}
/**
* Update the value of the key, and return the old value.
*
* @param key The key of the value to update.
* @param value The new value, or null to remove the value.
* @return The old value, or null if the value is not exist.
*/
public @Nullable T update(@NotNull K key, @Nullable T value) {
if (value == null) {
T current = valuesCache.remove(key);
removeHolder(key);
return current;
}
ConfigurationHolder<?> holder = holder(key);
write(holder, value);
return valuesCache.put(key, value);
}
}
@@ -0,0 +1,73 @@
package cc.carm.lib.configuration.multi;
import cc.carm.lib.configuration.source.ConfigurationHolder;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public abstract class MultiFileConfiguration<K, T> extends MultiConfiguration<K, T> {
protected final @NotNull File dataFolder;
protected final @NotNull String extensionSuffix; // e.g. ".yml"
protected final ConcurrentHashMap<K, ConfigurationHolder<?>> holders = new ConcurrentHashMap<>();
public MultiFileConfiguration(@NotNull File dataFolder, @NotNull String extensionSuffix) {
this.dataFolder = dataFolder;
this.extensionSuffix = extensionSuffix;
// Load existing configuration files
if (dataFolder.exists() && dataFolder.isDirectory()) {
File[] files = dataFolder.listFiles((dir, name) -> name.endsWith(extensionSuffix));
if (files != null) {
for (File file : files) {
String fileName = file.getName();
String keyStr = fileName.substring(0, fileName.length() - extensionSuffix.length()); // Remove extension suffix
try {
holders.put(extractKeyFromFilename(keyStr), loadHolder(file));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
loadAll();
}
public abstract K extractKeyFromFilename(@NotNull String fileName);
public String keyToFilename(@NotNull K key) {
return key.toString();
}
public abstract ConfigurationHolder<?> loadHolder(@NotNull File file);
@Override
public @NotNull Map<K, ConfigurationHolder<?>> holders() {
return this.holders;
}
@Override
public @NotNull ConfigurationHolder<?> holder(@NotNull K key) {
ConfigurationHolder<?> loaded = holders.get(key);
if (loaded != null) return loaded;
File file = new File(dataFolder, keyToFilename(key) + this.extensionSuffix);
ConfigurationHolder<?> created = loadHolder(file);
holders.put(key, created);
return created;
}
@Override
public void removeHolder(@NotNull K key) {
ConfigurationHolder<?> loaded = holders.remove(key);
if (loaded == null) return;
File file = new File(dataFolder, key + ".yml");
if (file.exists()) file.delete();
}
}
@@ -0,0 +1,77 @@
package cc.carm.lib.configuration.tests;
import cc.carm.lib.configuration.multi.MultiFileConfiguration;
import cc.carm.lib.configuration.source.ConfigurationHolder;
import cc.carm.lib.configuration.source.section.ConfigureSection;
import cc.carm.lib.configuration.source.yaml.YAMLConfigFactory;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import java.io.File;
import java.util.UUID;
public class MultiFileTests {
@Test
public void test() {
ProfileStorage storage = new ProfileStorage(new File(new File("target"), "test-profiles"));
// Add (or create) a new entry to file.
UserProfile profile = new UserProfile(UUID.randomUUID(), "John Doe", "john@google.com", "123123123");
storage.update(profile.getUniqueId(), profile);
// Read files.
System.out.println("Current users: ");
storage.values().forEach((k, v) -> {
System.out.println("# " + k);
System.out.println("- " + v.getName() + " (" + v.getEmail() + ", " + v.getPhone() + ")");
});
}
public static class ProfileStorage extends MultiFileConfiguration<UUID, UserProfile> {
public ProfileStorage(@NotNull File dataFolder) {
super(dataFolder, ".yml");
}
@Override
public UserProfile read(@NotNull UUID key, @NotNull ConfigurationHolder<?> holder) {
ConfigureSection conf = holder.config();
return new UserProfile(
key,
conf.getString("name", "Unknown"),
conf.getString("email", "unset"),
conf.getString("phone", "123123123")
);
}
@Override
public void write(@NotNull ConfigurationHolder<?> holder, @NotNull UserProfile value) {
ConfigureSection conf = holder.config();
conf.set("name", value.getName());
conf.set("email", value.getEmail());
conf.set("phone", value.getPhone());
try {
holder.save();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public UUID extractKeyFromFilename(@NotNull String fileName) {
return UUID.fromString(fileName);
}
@Override
public ConfigurationHolder<?> loadHolder(@NotNull File file) {
return YAMLConfigFactory.from(file).build();
}
}
}
@@ -0,0 +1,49 @@
package cc.carm.lib.configuration.tests;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import java.util.UUID;
public class UserProfile {
protected final @NotNull UUID uuid;
protected final @NotNull String name;
protected final @NotNull String email;
protected final @NotNull String phone;
public UserProfile(@NotNull UUID uuid, @NotNull String name, @NotNull String email, @NotNull String phone) {
this.uuid = uuid;
this.name = name;
this.email = email;
this.phone = phone;
}
public @NotNull UUID getUniqueId() {
return uuid;
}
public @NotNull String getName() {
return name;
}
public @NotNull String getEmail() {
return email;
}
public @NotNull String getPhone() {
return phone;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof UserProfile)) return false;
UserProfile that = (UserProfile) o;
return Objects.equals(name, that.name) && Objects.equals(email, that.email) && Objects.equals(phone, that.phone);
}
@Override
public int hashCode() {
return Objects.hash(name, email, phone);
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
@@ -39,7 +39,8 @@ public abstract class ContentInserter<RECEIVER> implements Comparable<ContentIns
@NotNull Insertable<RECEIVER, ?> insertions) {
Matcher matcher = matcher(line);
if (!matcher.matches()) return null;
if (!insertions.inserting(extractID(matcher))) return Collections.emptyList();
String id = extractID(matcher);
if (id == null || !insertions.inserting(id)) return Collections.emptyList();
return get(receiver, matcher, insertions);
}
@@ -47,8 +47,13 @@ public abstract class ContentReplacer<RECEIVER> implements Comparable<ContentRep
Matcher matcher = matcher(text);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
String replaced = get(receiver, matcher);
matcher.appendReplacement(sb, replaced == null ? "" : replaced);
try {
String replaced = get(receiver, matcher);
matcher.appendReplacement(sb, replaced == null ? "" : replaced);
} catch (Exception ex) {
// Do nothing if exception occurred.
ex.printStackTrace(); // for debug
}
}
matcher.appendTail(sb);
return sb.toString();
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
+11 -10
View File
@@ -10,13 +10,13 @@
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<kotlin.version>2.2.20</kotlin.version>
<kotlin.version>2.4.0</kotlin.version>
</properties>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<packaging>pom</packaging>
<version>4.2.0</version>
<version>4.2.1</version>
<modules>
<module>core</module>
<module>features/section</module>
@@ -37,6 +37,7 @@
<module>providers/mongodb</module>
<module>demo</module>
<module>features/multi</module>
</modules>
<name>configured</name>
@@ -121,7 +122,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>26.0.2-1</version>
<version>26.1.0</version>
<scope>provided</scope>
</dependency>
@@ -134,7 +135,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<version>3.5.6</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
@@ -162,7 +163,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.1.1</version>
<version>3.3.1</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
@@ -204,7 +205,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
<version>3.15.0</version>
<configuration>
<source>${project.jdk.version}</source>
<target>${project.jdk.version}</target>
@@ -216,13 +217,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<version>3.5.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<version>3.4.0</version>
<executions>
<execution>
<phase>package</phase>
@@ -236,7 +237,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.1</version>
<version>3.6.2</version>
<executions>
<execution>
<phase>package</phase>
@@ -283,7 +284,7 @@
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.9.0</version>
<version>0.10.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>configured-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -48,7 +48,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.13.2</version>
<version>2.14.0</version>
<scope>compile</scope>
</dependency>
+2 -2
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>configured-parent</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
@@ -50,7 +50,7 @@
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.4.5</version>
<version>1.4.9</version>
<scope>compile</scope>
</dependency>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>configured-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -14,7 +14,7 @@
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<deps.mongodb.version>5.6.0</deps.mongodb.version>
<deps.mongodb.version>5.8.0</deps.mongodb.version>
</properties>
<artifactId>configured-mongodb</artifactId>
<packaging>jar</packaging>
+2 -2
View File
@@ -6,7 +6,7 @@
<parent>
<artifactId>configured-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
@@ -54,7 +54,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.13.2</version>
<version>2.14.0</version>
</dependency>
<dependency>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<artifactId>configured-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
+2 -2
View File
@@ -6,7 +6,7 @@
<parent>
<artifactId>configured-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>4.2.0</version>
<version>4.2.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
@@ -63,7 +63,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.5</version>
<version>2.6</version>
<scope>compile</scope>
</dependency>