Class AbstractConfig
java.lang.Object
com.electronwill.nightconfig.core.AbstractConfig
- All Implemented Interfaces:
Config,UnmodifiableConfig,Cloneable
- Direct Known Subclasses:
AbstractCommentedConfig
An abstract Config that uses a
Map to store its values. In practice it's
often a HashMap, or a ConcurrentHashMap if the config is concurrent, but it accepts any type
of Map.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA wrapper around aMap.Entry<String, Object>.Nested classes/interfaces inherited from interface com.electronwill.nightconfig.core.Config
Config.Entry -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractConfig(boolean concurrent) Creates a new AbstractConfig backed by a newMap.AbstractConfig(UnmodifiableConfig toCopy, boolean concurrent) Creates a new AbstractConfig that is a copy of the specified config.AbstractConfig(UnmodifiableConfig toCopy, Supplier<Map<String, Object>> mapCreator) Creates a new AbstractConfig that is a copy of the specified config, and with all backing maps supplied by the givenSupplier.AbstractConfig(Supplier<Map<String, Object>> mapCreator) Creates a new AbstractConfig with all backing maps supplied by the givenSupplier.AbstractConfig(Map<String, Object> map) Creates a new AbstractConfig backed by the specifiedMap. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a config value.voidclear()Removes all values from the config.abstract AbstractConfigclone()Creates and return a copy of this config.booleanChecks if the config contains a value at some path.Set<? extends Config.Entry>entrySet()Returns a Set view of the config's entries.booleangetDefaultMapCreator(boolean concurrent) Returns a map supplier that fullfills the given requirements.<T> TGets a value from the config.getWildcardMapCreator(Supplier<Map<String, Object>> mapCreator) inthashCode()booleanChecks if the config contains a null value at some path.<T> TRemoves a value from the config.<T> TSets a config value.intsize()Gets the size of the config.toString()valueMap()Returns a Map view of the config's values.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.electronwill.nightconfig.core.Config
add, addAll, checked, createSubConfig, putAll, remove, removeAll, set, unmodifiable, update, updateMethods inherited from interface com.electronwill.nightconfig.core.UnmodifiableConfig
apply, apply, configFormat, contains, get, get, getByte, getByte, getByteOrElse, getByteOrElse, getChar, getChar, getCharOrElse, getCharOrElse, getEnum, getEnum, getEnum, getEnum, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getEnumOrElse, getInt, getInt, getIntOrElse, getIntOrElse, getIntOrElse, getIntOrElse, getLong, getLong, getLongOrElse, getLongOrElse, getLongOrElse, getLongOrElse, getOptional, getOptional, getOptionalEnum, getOptionalEnum, getOptionalEnum, getOptionalEnum, getOptionalInt, getOptionalInt, getOptionalLong, getOptionalLong, getOrElse, getOrElse, getOrElse, getOrElse, getRaw, getShort, getShort, getShortOrElse, getShortOrElse, isEmpty, isNull
-
Field Details
-
mapCreator
-
-
Constructor Details
-
AbstractConfig
public AbstractConfig(boolean concurrent) Creates a new AbstractConfig backed by a newMap. -
AbstractConfig
Creates a new AbstractConfig with all backing maps supplied by the givenSupplier.- Parameters:
mapCreator- A supplier that will be called to create all config maps
-
AbstractConfig
Creates a new AbstractConfig backed by the specifiedMap.- Parameters:
map- the map to use to store the config values.
-
AbstractConfig
Creates a new AbstractConfig that is a copy of the specified config.- Parameters:
toCopy- the config to copy
-
AbstractConfig
Creates a new AbstractConfig that is a copy of the specified config, and with all backing maps supplied by the givenSupplier.- Parameters:
toCopy- the config to copymapCreator- A supplier that will be called to create all config maps
-
-
Method Details
-
getDefaultMapCreator
Description copied from interface:ConfigReturns a map supplier that fullfills the given requirements. It preserves (or not) the insertion order of its values according toConfig.isInsertionOrderPreserved().- Parameters:
concurrent- true to make the maps thread-safe- Returns:
- a map supplier corresponding to the given settings
-
getWildcardMapCreator
-
getRaw
Description copied from interface:UnmodifiableConfigGets a value from the config. Doesn't convertNullObject.NULL_OBJECTtonull.- Specified by:
getRawin interfaceUnmodifiableConfig- Type Parameters:
T- the value's type- Parameters:
path- the value's path, each element of the list is a different part of the path.- Returns:
- the value at the given path, or
nullif there is no such value.
-
set
Description copied from interface:ConfigSets a config value. -
add
Description copied from interface:ConfigAdds a config value. The value is set iff there is no value associated with the given path. -
remove
Description copied from interface:ConfigRemoves a value from the config. -
contains
Description copied from interface:UnmodifiableConfigChecks if the config contains a value at some path.- Specified by:
containsin interfaceUnmodifiableConfig- Parameters:
path- the path to check, each element of the list is a different part of the path.- Returns:
trueif the path is associated with a value,falseif it's not.
-
isNull
Description copied from interface:UnmodifiableConfigChecks if the config contains a null value at some path.- Specified by:
isNullin interfaceUnmodifiableConfig- Parameters:
path- the path to check, each element of the list is a different part of the path.- Returns:
trueif the path is associated withNullObject.NULL_OBJECT,falseif it's associated with another value or with no value.
-
clear
public void clear()Description copied from interface:ConfigRemoves all values from the config. -
size
public int size()Description copied from interface:UnmodifiableConfigGets the size of the config.- Specified by:
sizein interfaceUnmodifiableConfig- Returns:
- the number of top-level elements in the config.
-
valueMap
Description copied from interface:ConfigReturns a Map view of the config's values. Any change to the map is reflected in the config and vice-versa.- Specified by:
valueMapin interfaceConfig- Specified by:
valueMapin interfaceUnmodifiableConfig- Returns:
- a Map view of the config's values.
-
entrySet
Description copied from interface:ConfigReturns a Set view of the config's entries. Any change to the set or to the entries is reflected in the config, and vice-versa.- Specified by:
entrySetin interfaceConfig- Specified by:
entrySetin interfaceUnmodifiableConfig- Returns:
- a Set view of the config's entries.
-
clone
Creates and return a copy of this config. -
hashCode
public int hashCode() -
equals
-
toString
-