mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2024-09-19 20:25:51 +00:00
feat(source): 为 ConfigurationWrapper 添加 getSource() 方法以获取源实现内容。
BREAKING-CHANGE: ConfigurationWrapper 更改为泛型类,并新增 “getSource” 方法需要实现。
This commit is contained in:
parent
f61294c5f3
commit
dc28d743db
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.2.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -9,13 +9,15 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface ConfigurationWrapper extends ConfigurationReader {
|
public interface ConfigurationWrapper<S> extends ConfigurationReader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default ConfigurationWrapper getWrapper() {
|
default ConfigurationWrapper<S> getWrapper() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull S getSource();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
Set<String> getKeys(boolean deep);
|
Set<String> getKeys(boolean deep);
|
||||||
|
|
||||||
@ -66,6 +68,6 @@ public interface ConfigurationWrapper extends ConfigurationReader {
|
|||||||
boolean isConfigurationSection(@NotNull String path);
|
boolean isConfigurationSection(@NotNull String path);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
ConfigurationWrapper getConfigurationSection(@NotNull String path);
|
ConfigurationWrapper<S> getConfigurationSection(@NotNull String path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.2.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -14,7 +14,7 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author md_5, CarmJos
|
* @author md_5, CarmJos
|
||||||
*/
|
*/
|
||||||
public class JSONConfigWrapper implements ConfigurationWrapper {
|
public class JSONConfigWrapper implements ConfigurationWrapper<Map<String, Object>> {
|
||||||
|
|
||||||
private static final char SEPARATOR = '.';
|
private static final char SEPARATOR = '.';
|
||||||
protected final Map<String, Object> data;
|
protected final Map<String, Object> data;
|
||||||
@ -33,6 +33,10 @@ public class JSONConfigWrapper implements ConfigurationWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Map<String, Object> getSource() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<String> getKeys(boolean deep) {
|
public @NotNull Set<String> getKeys(boolean deep) {
|
||||||
@ -94,7 +98,7 @@ public class JSONConfigWrapper implements ConfigurationWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable ConfigurationWrapper getConfigurationSection(@NotNull String path) {
|
public @Nullable JSONConfigWrapper getConfigurationSection(@NotNull String path) {
|
||||||
Object val = get(path);
|
Object val = get(path);
|
||||||
return (val instanceof JSONConfigWrapper) ? (JSONConfigWrapper) val : null;
|
return (val instanceof JSONConfigWrapper) ? (JSONConfigWrapper) val : null;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.2.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -8,7 +8,12 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class SQLSectionWrapper implements ConfigurationWrapper {
|
public class SQLSectionWrapper implements ConfigurationWrapper<Map<String, Object>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Map<String, Object> getSource() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<String> getKeys(boolean deep) {
|
public @NotNull Set<String> getKeys(boolean deep) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.2.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class YAMLSectionWrapper implements ConfigurationWrapper {
|
public class YAMLSectionWrapper implements ConfigurationWrapper<ConfigurationSection> {
|
||||||
|
|
||||||
private final ConfigurationSection section;
|
private final ConfigurationSection section;
|
||||||
|
|
||||||
@ -25,6 +25,11 @@ public class YAMLSectionWrapper implements ConfigurationWrapper {
|
|||||||
return section == null ? null : new YAMLSectionWrapper(section);
|
return section == null ? null : new YAMLSectionWrapper(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ConfigurationSection getSource() {
|
||||||
|
return this.section;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Set<String> getKeys(boolean deep) {
|
public @NotNull Set<String> getKeys(boolean deep) {
|
||||||
return new LinkedHashSet<>(section.getKeys(deep));
|
return new LinkedHashSet<>(section.getKeys(deep));
|
||||||
@ -66,7 +71,7 @@ public class YAMLSectionWrapper implements ConfigurationWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable ConfigurationWrapper getConfigurationSection(@NotNull String path) {
|
public @Nullable YAMLSectionWrapper getConfigurationSection(@NotNull String path) {
|
||||||
return of(this.section.getConfigurationSection(path));
|
return of(this.section.getConfigurationSection(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -15,7 +15,7 @@
|
|||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>3.1.0</version>
|
<version>3.2.0</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>impl/yaml</module>
|
<module>impl/yaml</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user