Class AbstractMapSection<R extends AbstractMapSection<R>>
- java.lang.Object
-
- cc.carm.lib.configuration.source.section.AbstractMapSection<R>
-
- All Implemented Interfaces:
ConfigureSection
- Direct Known Subclasses:
MemorySection,SourcedSection
public abstract class AbstractMapSection<R extends AbstractMapSection<R>> extends java.lang.Object implements ConfigureSection
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMapSection(R parent, @NotNull java.lang.String path)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @UnmodifiableView @NotNull java.util.Map<java.lang.String,java.lang.Object>asMap()Get this section as a map.booleancontains(@NotNull java.lang.String path)Check if the given path is present.abstract RcreateSection(@NotNull java.lang.String path, @NotNull java.util.Map<?,?> data)Creates a newConfigureSectionwith specified values.@NotNull java.util.Map<java.lang.String,java.lang.Object>data()@Nullable java.lang.Objectget(@NotNull java.lang.String path)Get the origin value of the path.@NotNull @UnmodifiableView java.util.Set<java.lang.String>getKeys(boolean deep)Gets a set containing all keys in this section.@NotNull java.util.Map<java.lang.String,java.lang.Object>getValues(boolean deep)Gets a set containing all values in this section.booleanisEmpty()Gets if this section is empty.protected static java.util.Set<java.lang.String>mappingKeys(@NotNull AbstractMapSection<?> section, @Nullable java.lang.String parent, boolean deep, java.lang.String pathSeparator)protected static java.util.Map<java.lang.String,java.lang.Object>mappingValues(@NotNull AbstractMapSection<?> section, @Nullable java.lang.String parent, boolean deep, java.lang.String pathSeparator)Map the values of the children of the section to the output map.voidmigrate(java.util.Map<?,?> data)Rparent()Gets the parent section of this section.@NotNull java.lang.Stringpath()Get the current section's path fromConfigureSection.parent()of this section.voidremove(@NotNull java.lang.String path)Removes the value at the given path.abstract Rself()voidset(@NotNull java.lang.String path, @Nullable java.lang.Object value)Sets the value at the given path.intsize(boolean deep)Gets the number of keys in this section.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cc.carm.lib.configuration.source.section.ConfigureSection
childPath, computeSection, computeSection, computeSection, computeSection, containsValue, createSection, createSection, createSection, forEach, fullPath, get, get, get, get, getBoolean, getBoolean, getByte, getByte, getByteList, getChar, getChar, getCharList, getCollection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInt, getInt, getIntegerList, getList, getList, getLong, getLong, getLongList, getSection, getShort, getShort, getString, getString, getStringList, isBoolean, isByte, isChar, isDouble, isFloat, isInt, isList, isLong, isRoot, isSection, isShort, isString, isType, keys, pathSeparator, stream, stream, stream, values
-
-
-
-
Field Detail
-
data
@NotNull protected final @NotNull java.util.Map<java.lang.String,java.lang.Object> data
-
parent
@Nullable protected final R extends AbstractMapSection<R> parent
-
path
@NotNull protected final @NotNull java.lang.String path
-
-
Constructor Detail
-
AbstractMapSection
protected AbstractMapSection(@Nullable R parent, @NotNull @NotNull java.lang.String path)
-
-
Method Detail
-
migrate
public void migrate(java.util.Map<?,?> data)
-
self
@NotNull public abstract R self()
-
createSection
@NotNull public abstract R createSection(@NotNull @NotNull java.lang.String path, @NotNull @NotNull java.util.Map<?,?> data)
Description copied from interface:ConfigureSectionCreates a newConfigureSectionwith specified values.The
ConfigureSection.parent()of the new section will be this section.This section will not be saved until
ConfigureSection.set(String, Object)is called.If you want to create and use a section and set it to this section, use
ConfigureSection.computeSection(String).- Specified by:
createSectionin interfaceConfigureSectiondata- The data to be used to create section.- Returns:
- Newly created section
-
path
@NotNull public @NotNull java.lang.String path()
Description copied from interface:ConfigureSectionGet the current section's path fromConfigureSection.parent()of this section.- Specified by:
pathin interfaceConfigureSection- Returns:
- The current path of this section, if
ConfigureSection.isRoot(), return empty string.
-
contains
public boolean contains(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigureSectionCheck if the given path is present.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR- Specified by:
containsin interfaceConfigureSection- Parameters:
path- The path to check.- Returns:
- True if the value is present, false otherwise.
-
data
@NotNull public @NotNull java.util.Map<java.lang.String,java.lang.Object> data()
-
isEmpty
public boolean isEmpty()
Description copied from interface:ConfigureSectionGets if this section is empty.- Specified by:
isEmptyin interfaceConfigureSection- Returns:
- True if this section is empty, false otherwise.
-
size
public int size(boolean deep)
Description copied from interface:ConfigureSectionGets the number of keys in this section.- Specified by:
sizein interfaceConfigureSection- Returns:
- Number of keys in this section.
-
asMap
@NotNull public @UnmodifiableView @NotNull java.util.Map<java.lang.String,java.lang.Object> asMap()
Description copied from interface:ConfigureSectionGet this section as a map.In this map, child
ConfigureSections will also be represented asMaps.- Specified by:
asMapin interfaceConfigureSection- Returns:
- Map of data values contained within this Section.
-
parent
@Nullable public R parent()
Description copied from interface:ConfigureSectionGets the parent section of this section.For root sections, this will return null.
- Specified by:
parentin interfaceConfigureSection- Returns:
- Parent section, or null if this is a root section.
-
getValues
@NotNull public @NotNull java.util.Map<java.lang.String,java.lang.Object> getValues(boolean deep)
Description copied from interface:ConfigureSectionGets a set containing all values in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSections (and their children paths).If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
- Specified by:
getValuesin interfaceConfigureSection- Parameters:
deep- Whether to get a deep list.- Returns:
- Map of data values contained within this Section.
-
getKeys
@NotNull public @NotNull @UnmodifiableView java.util.Set<java.lang.String> getKeys(boolean deep)
Description copied from interface:ConfigureSectionGets a set containing all keys in this section.If deep is set to true, then this will contain all the keys within any child
ConfigureSections (and their children paths).If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
- Specified by:
getKeysin interfaceConfigureSection- Parameters:
deep- Whether to get a deep list.- Returns:
- Set of keys contained within this Section.
-
set
public void set(@NotNull @NotNull java.lang.String path, @Nullable @Nullable java.lang.Object value)Description copied from interface:ConfigureSectionSets the value at the given path.Null values will be kept, if you want to remove a value use
ConfigureSection.remove(String)Path separator depends on holder'sStandardOptions.PATH_SEPARATOR- Specified by:
setin interfaceConfigureSection- Parameters:
path- The path to set the value at.value- The value to set.
-
remove
public void remove(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigureSectionRemoves the value at the given path.Path separator depends on holder's
StandardOptions.PATH_SEPARATOR- Specified by:
removein interfaceConfigureSection- Parameters:
path- The path to remove the value at.
-
get
@Nullable public @Nullable java.lang.Object get(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigureSectionGet the origin value of the path.- Specified by:
getin interfaceConfigureSection- Parameters:
path- The path to get the value from.- Returns:
- The value at the path, or null if not found.
-
mappingValues
protected static java.util.Map<java.lang.String,java.lang.Object> mappingValues(@NotNull @NotNull AbstractMapSection<?> section, @Nullable @Nullable java.lang.String parent, boolean deep, java.lang.String pathSeparator)Map the values of the children of the section to the output map.- Parameters:
section- The section to map the values fromparent- The parent pathdeep- If the mapping should be deep
-
mappingKeys
protected static java.util.Set<java.lang.String> mappingKeys(@NotNull @NotNull AbstractMapSection<?> section, @Nullable @Nullable java.lang.String parent, boolean deep, java.lang.String pathSeparator)
-
-