mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 18:48:20 +08:00
feat(section): Implement more sections
This commit is contained in:
@@ -19,7 +19,7 @@ import java.util.stream.Stream;
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public interface ConfigureSection extends Cloneable {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the parent section of this section.
|
||||
* <p>
|
||||
@@ -136,7 +136,9 @@ public interface ConfigureSection extends Cloneable {
|
||||
* @param path The path to check.
|
||||
* @return True if the value is present, false otherwise.
|
||||
*/
|
||||
boolean contains(@NotNull String path);
|
||||
default boolean contains(@NotNull String path) {
|
||||
return get(path) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predicate the value of given path is specific type.
|
||||
@@ -166,7 +168,10 @@ public interface ConfigureSection extends Cloneable {
|
||||
* @param path The path to get the {@link List}.
|
||||
* @return The list if the path exists and is a list, otherwise null.
|
||||
*/
|
||||
@Nullable List<?> getList(@NotNull String path);
|
||||
default @Nullable List<?> getList(@NotNull String path) {
|
||||
Object val = get(path);
|
||||
return (val instanceof List<?>) ? (List<?>) val : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predicate the value of given path is a {@link ConfigureSection}.
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -104,21 +103,11 @@ public abstract class ConfigureSource<
|
||||
section().set(path, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(@NotNull String path) {
|
||||
return section().contains(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(@NotNull String path) {
|
||||
section().remove(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<?> getList(@NotNull String path) {
|
||||
return section().getList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ConfigureSection getSection(@NotNull String path) {
|
||||
return section().getSection(path);
|
||||
|
||||
Reference in New Issue
Block a user