Class MemorySection
- All Implemented Interfaces:
ConfigurationSection
- Direct Known Subclasses:
MemoryConfiguration
public class MemorySection extends java.lang.Object implements ConfigurationSection
ConfigurationSection that is stored in memory.-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringfullPathprotected java.util.Map<java.lang.String,java.lang.Object>mapprivate ConfigurationSectionparentprivate java.lang.Stringpathprivate Configurationroot -
Constructor Summary
Constructors Modifier Constructor Description protectedMemorySection()Creates an empty MemorySection for use as a rootConfigurationsection.protectedMemorySection(@NotNull ConfigurationSection parent, @NotNull java.lang.String path)Creates an empty MemorySection with the specified parent and path. -
Method Summary
Modifier and Type Method Description voidaddDefault(@NotNull java.lang.String path, @Nullable java.lang.Object value)Sets the default value in the root at the given path as provided.booleancontains(@NotNull java.lang.String path)Checks if thisConfigurationSectioncontains the given path.booleancontains(@NotNull java.lang.String path, boolean ignoreDefault)Checks if thisConfigurationSectioncontains the given path.static @NotNull java.lang.StringcreatePath(@NotNull ConfigurationSection section, @Nullable java.lang.String key)Creates a full path to the givenConfigurationSectionfrom its rootConfiguration.static @NotNull java.lang.StringcreatePath(@NotNull ConfigurationSection section, @Nullable java.lang.String key, @Nullable ConfigurationSection relativeTo)Creates a relative path to the givenConfigurationSectionfrom the given relative section.@NotNull ConfigurationSectioncreateSection(@NotNull java.lang.String path)Creates an emptyConfigurationSectionat the specified path.@NotNull ConfigurationSectioncreateSection(@NotNull java.lang.String path, @NotNull java.util.Map<?,?> map)Creates aConfigurationSectionat the specified path, with specified values.@Nullable java.lang.Objectget(@NotNull java.lang.String path)Gets the requested Object by path.@Nullable java.lang.Objectget(@NotNull java.lang.String path, @Nullable java.lang.Object def)Gets the requested Object by path, returning a default value if not found.booleangetBoolean(@NotNull java.lang.String path)Gets the requested boolean by path.booleangetBoolean(@NotNull java.lang.String path, boolean def)Gets the requested boolean by path, returning a default value if not found.@NotNull java.util.List<java.lang.Boolean>getBooleanList(@NotNull java.lang.String path)Gets the requested List of Boolean by path.@NotNull java.util.List<java.lang.Byte>getByteList(@NotNull java.lang.String path)Gets the requested List of Byte by path.@NotNull java.util.List<java.lang.Character>getCharacterList(@NotNull java.lang.String path)Gets the requested List of Character by path.@Nullable ConfigurationSectiongetConfigurationSection(@NotNull java.lang.String path)Gets the requested ConfigurationSection by path.@NotNull java.lang.StringgetCurrentPath()Gets the path of thisConfigurationSectionfrom its rootConfigurationprotected @Nullable java.lang.ObjectgetDefault(@NotNull java.lang.String path)@Nullable ConfigurationSectiongetDefaultSection()Gets the equivalentConfigurationSectionfrom the defaultConfigurationdefined inConfigurationSection.getRoot().doublegetDouble(@NotNull java.lang.String path)Gets the requested double by path.doublegetDouble(@NotNull java.lang.String path, double def)Gets the requested double by path, returning a default value if not found.@NotNull java.util.List<java.lang.Double>getDoubleList(@NotNull java.lang.String path)Gets the requested List of Double by path.@NotNull java.util.List<java.lang.Float>getFloatList(@NotNull java.lang.String path)Gets the requested List of Float by path.intgetInt(@NotNull java.lang.String path)Gets the requested int by path.intgetInt(@NotNull java.lang.String path, int def)Gets the requested int by path, returning a default value if not found.@NotNull java.util.List<java.lang.Integer>getIntegerList(@NotNull java.lang.String path)Gets the requested List of Integer by path.@NotNull java.util.Set<java.lang.String>getKeys(boolean deep)Gets a set containing all keys in this section.@Nullable java.util.List<?>getList(@NotNull java.lang.String path)Gets the requested List by path.@Nullable java.util.List<?>getList(@NotNull java.lang.String path, @Nullable java.util.List<?> def)Gets the requested List by path, returning a default value if not found.longgetLong(@NotNull java.lang.String path)Gets the requested long by path.longgetLong(@NotNull java.lang.String path, long def)Gets the requested long by path, returning a default value if not found.@NotNull java.util.List<java.lang.Long>getLongList(@NotNull java.lang.String path)Gets the requested List of Long by path.@NotNull java.util.List<java.util.Map<?,?>>getMapList(@NotNull java.lang.String path)Gets the requested List of Maps by path.@NotNull java.lang.StringgetName()Gets the name of this individualConfigurationSection, in the path.<T> TgetObject(@NotNull java.lang.String path, @NotNull java.lang.Class<T> clazz)Gets the requested object at the given path.<T> TgetObject(@NotNull java.lang.String path, @NotNull java.lang.Class<T> clazz, T def)Gets the requested object at the given path, returning a default value if not found If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the rootConfiguration.@Nullable ConfigurationSectiongetParent()Gets the parentConfigurationSectionthat directly contains thisConfigurationSection.@Nullable ConfigurationgetRoot()Gets the rootConfigurationthat contains thisConfigurationSection<T extends ConfigurationSerializable>
TgetSerializable(@NotNull java.lang.String path, @NotNull java.lang.Class<T> clazz)Gets the requestedConfigurationSerializableobject at the given path.<T extends ConfigurationSerializable>
TgetSerializable(@NotNull java.lang.String path, @NotNull java.lang.Class<T> clazz, T def)Gets the requestedConfigurationSerializableobject at the given path, returning a default value if not found If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the rootConfiguration.@NotNull java.util.List<java.lang.Short>getShortList(@NotNull java.lang.String path)Gets the requested List of Short by path.@Nullable java.lang.StringgetString(@NotNull java.lang.String path)Gets the requested String by path.@Nullable java.lang.StringgetString(@NotNull java.lang.String path, @Nullable java.lang.String def)Gets the requested String by path, returning a default value if not found.@NotNull java.util.List<java.lang.String>getStringList(@NotNull java.lang.String path)Gets the requested List of String by path.@NotNull java.util.Map<java.lang.String,java.lang.Object>getValues(boolean deep)Gets a Map containing all keys and their values for this section.booleanisBoolean(@NotNull java.lang.String path)Checks if the specified path is a boolean.booleanisConfigurationSection(@NotNull java.lang.String path)Checks if the specified path is a ConfigurationSection.booleanisDouble(@NotNull java.lang.String path)Checks if the specified path is a double.booleanisInt(@NotNull java.lang.String path)Checks if the specified path is an int.booleanisList(@NotNull java.lang.String path)Checks if the specified path is a List.booleanisLong(@NotNull java.lang.String path)Checks if the specified path is a long.protected booleanisPrimitiveWrapper(@Nullable java.lang.Object input)booleanisSet(@NotNull java.lang.String path)Checks if thisConfigurationSectionhas a value set for the given path.booleanisString(@NotNull java.lang.String path)Checks if the specified path is a String.protected voidmapChildrenKeys(@NotNull java.util.Set<java.lang.String> output, @NotNull ConfigurationSection section, boolean deep)protected voidmapChildrenValues(@NotNull java.util.Map<java.lang.String,java.lang.Object> output, @NotNull ConfigurationSection section, boolean deep)voidset(@NotNull java.lang.String path, @Nullable java.lang.Object value)Sets the specified path to the given value.java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
map
protected final java.util.Map<java.lang.String,java.lang.Object> map -
root
-
parent
-
path
private final java.lang.String path -
fullPath
private final java.lang.String fullPath
-
-
Constructor Details
-
MemorySection
protected MemorySection()Creates an empty MemorySection for use as a rootConfigurationsection.Note that calling this without being yourself a
Configurationwill throw an exception!- Throws:
java.lang.IllegalStateException- Thrown if this is not aConfigurationroot.
-
MemorySection
protected MemorySection(@NotNull @NotNull ConfigurationSection parent, @NotNull @NotNull java.lang.String path)Creates an empty MemorySection with the specified parent and path.- Parameters:
parent- Parent section that contains this own section.path- Path that you may access this section from via the rootConfiguration.- Throws:
java.lang.IllegalArgumentException- Thrown is parent or path is null, or if parent contains no root Configuration.
-
-
Method Details
-
getKeys
@NotNull public @NotNull java.util.Set<java.lang.String> getKeys(boolean deep)Description copied from interface:ConfigurationSectionGets a set containing all keys in this section.If deep is set to true, then this will contain all the keys within any child
ConfigurationSections (and their children, etc). These will be in a valid path notation for you to use.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 interfaceConfigurationSection- Parameters:
deep- Whether or not to get a deep list, as opposed to a shallow list.- Returns:
- Set of keys contained within this ConfigurationSection.
-
getValues
@NotNull public @NotNull java.util.Map<java.lang.String,java.lang.Object> getValues(boolean deep)Description copied from interface:ConfigurationSectionGets a Map containing all keys and their values for this section.If deep is set to true, then this will contain all the keys and values within any child
ConfigurationSections (and their children, etc). These keys will be in a valid path notation for you to use.If deep is set to false, then this will contain only the keys and values of any direct children, and not their own children.
- Specified by:
getValuesin interfaceConfigurationSection- Parameters:
deep- Whether or not to get a deep list, as opposed to a shallow list.- Returns:
- Map of keys and values of this section.
-
contains
public boolean contains(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if thisConfigurationSectioncontains the given path.If the value for the requested path does not exist but a default value has been specified, this will return true.
- Specified by:
containsin interfaceConfigurationSection- Parameters:
path- Path to check for existence.- Returns:
- True if this section contains the requested path, either via default or being set.
-
contains
public boolean contains(@NotNull @NotNull java.lang.String path, boolean ignoreDefault)Description copied from interface:ConfigurationSectionChecks if thisConfigurationSectioncontains the given path.If the value for the requested path does not exist, the boolean parameter of true has been specified, a default value for the path exists, this will return true.
If a boolean parameter of false has been specified, true will only be returned if there is a set value for the specified path.
- Specified by:
containsin interfaceConfigurationSection- Parameters:
path- Path to check for existence.ignoreDefault- Whether or not to ignore if a default value for the specified path exists.- Returns:
- True if this section contains the requested path, or if a default value exist and the boolean parameter for this method is true.
-
isSet
public boolean isSet(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if thisConfigurationSectionhas a value set for the given path.If the value for the requested path does not exist but a default value has been specified, this will still return false.
- Specified by:
isSetin interfaceConfigurationSection- Parameters:
path- Path to check for existence.- Returns:
- True if this section contains the requested path, regardless of having a default.
-
getCurrentPath
@NotNull public @NotNull java.lang.String getCurrentPath()Description copied from interface:ConfigurationSectionGets the path of thisConfigurationSectionfrom its rootConfigurationFor any
Configurationthemselves, this will return an empty string.If the section is no longer contained within its root for any reason, such as being replaced with a different value, this may return null.
To retrieve the single name of this section, that is, the final part of the path returned by this method, you may use
ConfigurationSection.getName().- Specified by:
getCurrentPathin interfaceConfigurationSection- Returns:
- Path of this section relative to its root
-
getName
@NotNull public @NotNull java.lang.String getName()Description copied from interface:ConfigurationSectionGets the name of this individualConfigurationSection, in the path.This will always be the final part of
ConfigurationSection.getCurrentPath(), unless the section is orphaned.- Specified by:
getNamein interfaceConfigurationSection- Returns:
- Name of this section
-
getRoot
Description copied from interface:ConfigurationSectionGets the rootConfigurationthat contains thisConfigurationSectionFor any
Configurationthemselves, this will return its own object.If the section is no longer contained within its root for any reason, such as being replaced with a different value, this may return null.
- Specified by:
getRootin interfaceConfigurationSection- Returns:
- Root configuration containing this section.
-
getParent
Description copied from interface:ConfigurationSectionGets the parentConfigurationSectionthat directly contains thisConfigurationSection.For any
Configurationthemselves, this will return null.If the section is no longer contained within its parent for any reason, such as being replaced with a different value, this may return null.
- Specified by:
getParentin interfaceConfigurationSection- Returns:
- Parent section containing this section.
-
addDefault
public void addDefault(@NotNull @NotNull java.lang.String path, @Nullable @Nullable java.lang.Object value)Description copied from interface:ConfigurationSectionSets the default value in the root at the given path as provided.If no source
Configurationwas provided as a default collection, then a newMemoryConfigurationwill be created to hold the new default value.If value is null, the value will be removed from the default Configuration source.
If the value as returned by
ConfigurationSection.getDefaultSection()is null, then this will create a new section at the path, replacing anything that may have existed there previously.- Specified by:
addDefaultin interfaceConfigurationSection- Parameters:
path- Path of the value to set.value- Value to set the default to.
-
getDefaultSection
Description copied from interface:ConfigurationSectionGets the equivalentConfigurationSectionfrom the defaultConfigurationdefined inConfigurationSection.getRoot().If the root contains no defaults, or the defaults doesn't contain a value for this path, or the value at this path is not a
ConfigurationSectionthen this will return null.- Specified by:
getDefaultSectionin interfaceConfigurationSection- Returns:
- Equivalent section in root configuration
-
set
public void set(@NotNull @NotNull java.lang.String path, @Nullable @Nullable java.lang.Object value)Description copied from interface:ConfigurationSectionSets the specified path to the given value.If value is null, the entry will be removed. Any existing entry will be replaced, regardless of what the new value is.
Some implementations may have limitations on what you may store. See their individual javadocs for details. No implementations should allow you to store
Configurations orConfigurationSections, please useConfigurationSection.createSection(java.lang.String)for that.- Specified by:
setin interfaceConfigurationSection- Parameters:
path- Path of the object to set.value- New value to set the path to.
-
get
@Nullable public @Nullable java.lang.Object get(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested Object by path.If the Object does not exist but a default value has been specified, this will return the default value. If the Object does not exist and no default value was specified, this will return null.
- Specified by:
getin interfaceConfigurationSection- Parameters:
path- Path of the Object to get.- Returns:
- Requested Object.
-
get
@Nullable public @Nullable java.lang.Object get(@NotNull @NotNull java.lang.String path, @Nullable @Nullable java.lang.Object def)Description copied from interface:ConfigurationSectionGets the requested Object by path, returning a default value if not found.If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration.- Specified by:
getin interfaceConfigurationSection- Parameters:
path- Path of the Object to get.def- The default value to return if the path is not found.- Returns:
- Requested Object.
-
createSection
@NotNull public @NotNull ConfigurationSection createSection(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionCreates an emptyConfigurationSectionat the specified path.Any value that was previously set at this path will be overwritten. If the previous value was itself a
ConfigurationSection, it will be orphaned.- Specified by:
createSectionin interfaceConfigurationSection- Parameters:
path- Path to create the section at.- Returns:
- Newly created section
-
createSection
@NotNull public @NotNull ConfigurationSection createSection(@NotNull @NotNull java.lang.String path, @NotNull @NotNull java.util.Map<?,?> map)Description copied from interface:ConfigurationSectionCreates aConfigurationSectionat the specified path, with specified values.Any value that was previously set at this path will be overwritten. If the previous value was itself a
ConfigurationSection, it will be orphaned.- Specified by:
createSectionin interfaceConfigurationSection- Parameters:
path- Path to create the section at.map- The values to used.- Returns:
- Newly created section
-
getString
@Nullable public @Nullable java.lang.String getString(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested String by path.If the String does not exist but a default value has been specified, this will return the default value. If the String does not exist and no default value was specified, this will return null.
- Specified by:
getStringin interfaceConfigurationSection- Parameters:
path- Path of the String to get.- Returns:
- Requested String.
-
getString
@Nullable public @Nullable java.lang.String getString(@NotNull @NotNull java.lang.String path, @Nullable @Nullable java.lang.String def)Description copied from interface:ConfigurationSectionGets the requested String by path, returning a default value if not found.If the String does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration.- Specified by:
getStringin interfaceConfigurationSection- Parameters:
path- Path of the String to get.def- The default value to return if the path is not found or is not a String.- Returns:
- Requested String.
-
isString
public boolean isString(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if the specified path is a String.If the path exists but is not a String, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a String and return appropriately.
- Specified by:
isStringin interfaceConfigurationSection- Parameters:
path- Path of the String to check.- Returns:
- Whether or not the specified path is a String.
-
getInt
public int getInt(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested int by path.If the int does not exist but a default value has been specified, this will return the default value. If the int does not exist and no default value was specified, this will return 0.
- Specified by:
getIntin interfaceConfigurationSection- Parameters:
path- Path of the int to get.- Returns:
- Requested int.
-
getInt
public int getInt(@NotNull @NotNull java.lang.String path, int def)Description copied from interface:ConfigurationSectionGets the requested int by path, returning a default value if not found.If the int does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration.- Specified by:
getIntin interfaceConfigurationSection- Parameters:
path- Path of the int to get.def- The default value to return if the path is not found or is not an int.- Returns:
- Requested int.
-
isInt
public boolean isInt(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if the specified path is an int.If the path exists but is not a int, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a int and return appropriately.
- Specified by:
isIntin interfaceConfigurationSection- Parameters:
path- Path of the int to check.- Returns:
- Whether or not the specified path is an int.
-
getBoolean
public boolean getBoolean(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested boolean by path.If the boolean does not exist but a default value has been specified, this will return the default value. If the boolean does not exist and no default value was specified, this will return false.
- Specified by:
getBooleanin interfaceConfigurationSection- Parameters:
path- Path of the boolean to get.- Returns:
- Requested boolean.
-
getBoolean
public boolean getBoolean(@NotNull @NotNull java.lang.String path, boolean def)Description copied from interface:ConfigurationSectionGets the requested boolean by path, returning a default value if not found.If the boolean does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration.- Specified by:
getBooleanin interfaceConfigurationSection- Parameters:
path- Path of the boolean to get.def- The default value to return if the path is not found or is not a boolean.- Returns:
- Requested boolean.
-
isBoolean
public boolean isBoolean(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if the specified path is a boolean.If the path exists but is not a boolean, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a boolean and return appropriately.
- Specified by:
isBooleanin interfaceConfigurationSection- Parameters:
path- Path of the boolean to check.- Returns:
- Whether or not the specified path is a boolean.
-
getDouble
public double getDouble(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested double by path.If the double does not exist but a default value has been specified, this will return the default value. If the double does not exist and no default value was specified, this will return 0.
- Specified by:
getDoublein interfaceConfigurationSection- Parameters:
path- Path of the double to get.- Returns:
- Requested double.
-
getDouble
public double getDouble(@NotNull @NotNull java.lang.String path, double def)Description copied from interface:ConfigurationSectionGets the requested double by path, returning a default value if not found.If the double does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration.- Specified by:
getDoublein interfaceConfigurationSection- Parameters:
path- Path of the double to get.def- The default value to return if the path is not found or is not a double.- Returns:
- Requested double.
-
isDouble
public boolean isDouble(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if the specified path is a double.If the path exists but is not a double, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a double and return appropriately.
- Specified by:
isDoublein interfaceConfigurationSection- Parameters:
path- Path of the double to check.- Returns:
- Whether or not the specified path is a double.
-
getLong
public long getLong(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested long by path.If the long does not exist but a default value has been specified, this will return the default value. If the long does not exist and no default value was specified, this will return 0.
- Specified by:
getLongin interfaceConfigurationSection- Parameters:
path- Path of the long to get.- Returns:
- Requested long.
-
getLong
public long getLong(@NotNull @NotNull java.lang.String path, long def)Description copied from interface:ConfigurationSectionGets the requested long by path, returning a default value if not found.If the long does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration.- Specified by:
getLongin interfaceConfigurationSection- Parameters:
path- Path of the long to get.def- The default value to return if the path is not found or is not a long.- Returns:
- Requested long.
-
isLong
public boolean isLong(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if the specified path is a long.If the path exists but is not a long, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a long and return appropriately.
- Specified by:
isLongin interfaceConfigurationSection- Parameters:
path- Path of the long to check.- Returns:
- Whether or not the specified path is a long.
-
getList
@Nullable public @Nullable java.util.List<?> getList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return null.
- Specified by:
getListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List.
-
getList
@Nullable public @Nullable java.util.List<?> getList(@NotNull @NotNull java.lang.String path, @Nullable @Nullable java.util.List<?> def)Description copied from interface:ConfigurationSectionGets the requested List by path, returning a default value if not found.If the List does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration.- Specified by:
getListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.def- The default value to return if the path is not found or is not a List.- Returns:
- Requested List.
-
isList
public boolean isList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if the specified path is a List.If the path exists but is not a List, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a List and return appropriately.
- Specified by:
isListin interfaceConfigurationSection- Parameters:
path- Path of the List to check.- Returns:
- Whether or not the specified path is a List.
-
getStringList
@NotNull public @NotNull java.util.List<java.lang.String> getStringList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of String by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a String if possible, but may miss any values out if they are not compatible.
- Specified by:
getStringListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of String.
-
getIntegerList
@NotNull public @NotNull java.util.List<java.lang.Integer> getIntegerList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Integer by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Integer if possible, but may miss any values out if they are not compatible.
- Specified by:
getIntegerListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Integer.
-
getBooleanList
@NotNull public @NotNull java.util.List<java.lang.Boolean> getBooleanList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Boolean by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Boolean if possible, but may miss any values out if they are not compatible.
- Specified by:
getBooleanListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Boolean.
-
getDoubleList
@NotNull public @NotNull java.util.List<java.lang.Double> getDoubleList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Double by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Double if possible, but may miss any values out if they are not compatible.
- Specified by:
getDoubleListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Double.
-
getFloatList
@NotNull public @NotNull java.util.List<java.lang.Float> getFloatList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Float by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Float if possible, but may miss any values out if they are not compatible.
- Specified by:
getFloatListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Float.
-
getLongList
@NotNull public @NotNull java.util.List<java.lang.Long> getLongList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Long by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Long if possible, but may miss any values out if they are not compatible.
- Specified by:
getLongListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Long.
-
getByteList
@NotNull public @NotNull java.util.List<java.lang.Byte> getByteList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Byte by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Byte if possible, but may miss any values out if they are not compatible.
- Specified by:
getByteListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Byte.
-
getCharacterList
@NotNull public @NotNull java.util.List<java.lang.Character> getCharacterList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Character by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Character if possible, but may miss any values out if they are not compatible.
- Specified by:
getCharacterListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Character.
-
getShortList
@NotNull public @NotNull java.util.List<java.lang.Short> getShortList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Short by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Short if possible, but may miss any values out if they are not compatible.
- Specified by:
getShortListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Short.
-
getMapList
@NotNull public @NotNull java.util.List<java.util.Map<?,?>> getMapList(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested List of Maps by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Map if possible, but may miss any values out if they are not compatible.
- Specified by:
getMapListin interfaceConfigurationSection- Parameters:
path- Path of the List to get.- Returns:
- Requested List of Maps.
-
getObject
@Nullable public <T> T getObject(@NotNull @NotNull java.lang.String path, @NotNull @NotNull java.lang.Class<T> clazz)Description copied from interface:ConfigurationSectionGets the requested object at the given path. If the Object does not exist but a default value has been specified, this will return the default value. If the Object does not exist and no default value was specified, this will return null. Note: For example #getObject(path, String.class) is not equivalent to#getString(path)because#getString(path)converts internally all Objects to Strings. However, #getObject(path, Boolean.class) is equivalent to#getBoolean(path)for example.- Specified by:
getObjectin interfaceConfigurationSection- Type Parameters:
T- the type of the requested object- Parameters:
path- the path to the object.clazz- the type of the requested object- Returns:
- Requested object
-
getObject
@Nullable public <T> T getObject(@NotNull @NotNull java.lang.String path, @NotNull @NotNull java.lang.Class<T> clazz, @Nullable T def)Description copied from interface:ConfigurationSectionGets the requested object at the given path, returning a default value if not found If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the rootConfiguration. Note: For example #getObject(path, String.class, def) is not equivalent to#getString(path, def)because#getString(path, def)converts internally all Objects to Strings. However, #getObject(path, Boolean.class, def) is equivalent to#getBoolean(path, def)for example.- Specified by:
getObjectin interfaceConfigurationSection- Type Parameters:
T- the type of the requested object- Parameters:
path- the path to the object.clazz- the type of the requested objectdef- the default object to return if the object is not present at the path- Returns:
- Requested object
-
getSerializable
@Nullable public <T extends ConfigurationSerializable> T getSerializable(@NotNull @NotNull java.lang.String path, @NotNull @NotNull java.lang.Class<T> clazz)Description copied from interface:ConfigurationSectionGets the requestedConfigurationSerializableobject at the given path. If the Object does not exist but a default value has been specified, this will return the default value. If the Object does not exist and no default value was specified, this will return null.- Specified by:
getSerializablein interfaceConfigurationSection- Type Parameters:
T- the type ofConfigurationSerializable- Parameters:
path- the path to the object.clazz- the type ofConfigurationSerializable- Returns:
- Requested
ConfigurationSerializableobject
-
getSerializable
@Nullable public <T extends ConfigurationSerializable> T getSerializable(@NotNull @NotNull java.lang.String path, @NotNull @NotNull java.lang.Class<T> clazz, @Nullable T def)Description copied from interface:ConfigurationSectionGets the requestedConfigurationSerializableobject at the given path, returning a default value if not found If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the rootConfiguration.- Specified by:
getSerializablein interfaceConfigurationSection- Type Parameters:
T- the type ofConfigurationSerializable- Parameters:
path- the path to the object.clazz- the type ofConfigurationSerializabledef- the default object to return if the object is not present at the path- Returns:
- Requested
ConfigurationSerializableobject
-
getConfigurationSection
@Nullable public @Nullable ConfigurationSection getConfigurationSection(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionGets the requested ConfigurationSection by path.If the ConfigurationSection does not exist but a default value has been specified, this will return the default value. If the ConfigurationSection does not exist and no default value was specified, this will return null.
- Specified by:
getConfigurationSectionin interfaceConfigurationSection- Parameters:
path- Path of the ConfigurationSection to get.- Returns:
- Requested ConfigurationSection.
-
isConfigurationSection
public boolean isConfigurationSection(@NotNull @NotNull java.lang.String path)Description copied from interface:ConfigurationSectionChecks if the specified path is a ConfigurationSection.If the path exists but is not a ConfigurationSection, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a ConfigurationSection and return appropriately.
- Specified by:
isConfigurationSectionin interfaceConfigurationSection- Parameters:
path- Path of the ConfigurationSection to check.- Returns:
- Whether or not the specified path is a ConfigurationSection.
-
isPrimitiveWrapper
protected boolean isPrimitiveWrapper(@Nullable @Nullable java.lang.Object input) -
getDefault
@Nullable protected @Nullable java.lang.Object getDefault(@NotNull @NotNull java.lang.String path) -
mapChildrenKeys
protected void mapChildrenKeys(@NotNull @NotNull java.util.Set<java.lang.String> output, @NotNull @NotNull ConfigurationSection section, boolean deep) -
mapChildrenValues
protected void mapChildrenValues(@NotNull @NotNull java.util.Map<java.lang.String,java.lang.Object> output, @NotNull @NotNull ConfigurationSection section, boolean deep) -
createPath
@NotNull public static @NotNull java.lang.String createPath(@NotNull @NotNull ConfigurationSection section, @Nullable @Nullable java.lang.String key)Creates a full path to the givenConfigurationSectionfrom its rootConfiguration.You may use this method for any given
ConfigurationSection, not onlyMemorySection.- Parameters:
section- Section to create a path for.key- Name of the specified section.- Returns:
- Full path of the section from its root.
-
createPath
@NotNull public static @NotNull java.lang.String createPath(@NotNull @NotNull ConfigurationSection section, @Nullable @Nullable java.lang.String key, @Nullable @Nullable ConfigurationSection relativeTo)Creates a relative path to the givenConfigurationSectionfrom the given relative section.You may use this method for any given
ConfigurationSection, not onlyMemorySection.- Parameters:
section- Section to create a path for.key- Name of the specified section.relativeTo- Section to create the path relative to.- Returns:
- Full path of the section from its root.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-